Class: Addressing::FieldOverrides

Inherits:
Object
  • Object
show all
Defined in:
lib/addressing/field_override.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ FieldOverrides

Returns a new instance of FieldOverrides.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/addressing/field_override.rb', line 13

def initialize(definition)
  AddressField.assert_all_exist(definition.keys)
  FieldOverride.assert_all_exist(definition.values)

  @hidden_fields = []
  @optional_fields = []
  @required_fields = []

  definition.each do |field, override|
    case override
    when FieldOverride::HIDDEN
      @hidden_fields << field
    when FieldOverride::OPTIONAL
      @optional_fields << field
    when FieldOverride::REQUIRED
      @required_fields << field
    end
  end
end

Instance Attribute Details

#hidden_fieldsObject (readonly)

Returns the value of attribute hidden_fields.



11
12
13
# File 'lib/addressing/field_override.rb', line 11

def hidden_fields
  @hidden_fields
end

#optional_fieldsObject (readonly)

Returns the value of attribute optional_fields.



11
12
13
# File 'lib/addressing/field_override.rb', line 11

def optional_fields
  @optional_fields
end

#required_fieldsObject (readonly)

Returns the value of attribute required_fields.



11
12
13
# File 'lib/addressing/field_override.rb', line 11

def required_fields
  @required_fields
end