Module: RestrictedEnumeration::ClassMethods

Defined in:
lib/ship_me/restricted_enumeration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#enumsObject (readonly)

Returns the value of attribute enums.



12
13
14
# File 'lib/ship_me/restricted_enumeration.rb', line 12

def enums
  @enums
end

Instance Method Details

#enum(*args, &blk) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ship_me/restricted_enumeration.rb', line 14

def enum(*args, &blk)
  @enums ||= []
  args.each do |enum_name_or_hash|

    case enum_name_or_hash
    when Hash
      enum_name_or_hash.each do |name, value|
        setup_enum(name, value, &blk)
      end
    else
      setup_enum(enum_name_or_hash, &blk)
    end
  end
end

#xml_enum(*args) ⇒ Object



29
30
31
32
33
# File 'lib/ship_me/restricted_enumeration.rb', line 29

def xml_enum(*args)
  enum(*args) do |e, name, value|
    e.value = value || name.to_s
  end
end