Class: GlobalPhone::Record
- Inherits:
-
Object
- Object
- GlobalPhone::Record
- Extended by:
- Forwardable
- Defined in:
- lib/global_phone/record.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Record
constructor
A new instance of Record.
Constructor Details
#initialize(data) ⇒ Record
Returns a new instance of Record.
22 23 24 |
# File 'lib/global_phone/record.rb', line 22 def initialize(data) @data = data end |
Class Method Details
.field(index, name, options = {}, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/global_phone/record.rb', line 7 def self.field(index, name, = {}, &block) if block transform_method_name = :"transform_field_#{name}" define_method(transform_method_name, block) end class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} value = @data[#{index.inspect}] #{"value = #{transform_method_name}(value) if value" if block} value #{"|| #{[:fallback]}" if [:fallback]} end RUBY end |