Class: Ebay::Schema::Enumeration

Inherits:
Object
  • Object
show all
Includes:
Inflections
Defined in:
lib/ebay/schema/mapper/enumeration.rb

Constant Summary

Constants included from Inflections

Inflections::DOWNCASE_TOKENS, Inflections::NAME_MAPPINGS, Inflections::UPCASE_TOKENS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inflections

#downcase_first_character, #ebay_camelize, #ebay_underscore, #underscore, #upcase_first_character

Constructor Details

#initialize(codes = []) ⇒ Enumeration

Returns a new instance of Enumeration.


7
8
9
10
# File 'lib/ebay/schema/mapper/enumeration.rb', line 7

def initialize(codes = [])
  codes.delete('CustomCode')
  @codes = codes
end

Instance Attribute Details

#codesObject

Returns the value of attribute codes


6
7
8
# File 'lib/ebay/schema/mapper/enumeration.rb', line 6

def codes
  @codes
end

Instance Method Details

#to_sObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ebay/schema/mapper/enumeration.rb', line 12

def to_s
  <<-END
CODES = #{@codes.inspect}


class << self
  def codes
    CODES
  end
  
  CODES.each do |code|
    define_method(ebay_underscore(code) do
new(code)
    end
  end
end
  END
end