Skip to content

Attribute aliases work only partially #237

Open
@Temikus

Description

@Temikus

For example, we create a model with those attributes:

(#<Fog::Compute::Google::Network>)> attributes
=> {:name=>"fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154", :ipv4_range=>"10.240.133.0/24"}

When created actually turns into proper model fields:

=> {:name=>"fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154", :ipv4_range=>"10.240.133.0/24"}
my_network
=>   <Fog::Compute::Google::Network
    name="fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154",
    auto_create_subnetworks=nil,
    creation_timestamp="2018-04-12T22:59:17.787-07:00",
    description=nil,
    gateway_i_pv4="10.240.0.1",
    i_pv4_range="10.240.0.0/16",
    id=REDACTED,
    kind="compute#network",
    peerings=nil,
    routing_config={:routing_mode=>"REGIONAL"},
    self_link="https://www.googleapis.com/compute/v1/projects/REDACTED/global/networks/fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154",
    subnetworks=nil

But when I try to call it:

NoMethodError: undefined method `ipv4_range' for #<Fog::Compute::Google::Network:0x00007fe5221bae40>
Did you mean?  i_pv4_range
               i_pv4_range=
from (pry):3:in `test_network_workflow'```

It seems there is a bug - the alias mapping is only being done when doing a plain new object or reloading:

if self.class.aliases[key]

But the actual method setters don't:
https://github.com/fog/fog-core/tree/master/lib/fog/core/attributes

Maybe we should move that alias code to inside the setter definition or do an alias automatically?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions