Class: Models::UserInfo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ UserInfo

Returns a new instance of UserInfo.



4
5
6
7
8
9
10
11
12
# File 'lib/models/user_info.rb', line 4

def initialize(args)
  @attributes = []
  args.each do |key, value|
    @attributes << key
    define_singleton_method(key) do
      value
    end
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/models/user_info.rb', line 3

def attributes
  @attributes
end

Instance Method Details

#as_jsonObject



14
15
16
17
18
# File 'lib/models/user_info.rb', line 14

def as_json
  @attributes.each_with_object({}) do |attr_name, hsh|
    hsh[attr_name.to_s] = public_send attr_name
  end
end