Class: Rhapsody::Member

Inherits:
Object
  • Object
show all
Defined in:
lib/rhapsody/models/member.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Member

Returns a new instance of Member.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rhapsody/models/member.rb', line 17

def initialize(options)
  if options
    self.attr_list = []

    options.each do |key, value|
      key = Rhapsody::Member.to_camelcase(key)

      # Set attr_accessor dynamically
      Rhapsody::Member.define_attr_accessor(key)
      self.attr_list << key

      # Set value for the attribute
      send("#{key}=", value)
    end
  end
end

Instance Attribute Details

#attr_listObject

Returns the value of attribute attr_list.



4
5
6
# File 'lib/rhapsody/models/member.rb', line 4

def attr_list
  @attr_list
end

Class Method Details

.define_attr_accessor(key) ⇒ Object

TODO: This needs to be global / base



8
9
10
# File 'lib/rhapsody/models/member.rb', line 8

def define_attr_accessor(key)
  __send__(:attr_accessor, key)
end

.to_camelcase(key) ⇒ Object



12
13
14
# File 'lib/rhapsody/models/member.rb', line 12

def to_camelcase(key)
  key.to_s.underscore
end