Class: Bkblz::V1::Model::BaseModel
- Inherits:
-
Object
- Object
- Bkblz::V1::Model::BaseModel
- Defined in:
- lib/bkblz/v1/model_base.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(map) ⇒ BaseModel
constructor
A new instance of BaseModel.
- #to_map ⇒ Object
- #to_s ⇒ Object
- #to_yaml ⇒ Object
Constructor Details
#initialize(map) ⇒ BaseModel
Returns a new instance of BaseModel.
25 26 27 |
# File 'lib/bkblz/v1/model_base.rb', line 25 def initialize(map) @map = map end |
Class Method Details
.field_accessors(*fields) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bkblz/v1/model_base.rb', line 16 def field_accessors(*fields) fields.each do |field| define_method field do |*args| @map[field] end end end |
Instance Method Details
#to_map ⇒ Object
29 30 31 |
# File 'lib/bkblz/v1/model_base.rb', line 29 def to_map @map.dup end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/bkblz/v1/model_base.rb', line 37 def to_s "#<%s:%d %s>" % [self.class.name, __id__, @map] end |
#to_yaml ⇒ Object
33 34 35 |
# File 'lib/bkblz/v1/model_base.rb', line 33 def to_yaml @map.to_yaml end |