Class: Bkblz::V1::Model::BaseModel

Inherits:
Object
  • Object
show all
Defined in:
lib/bkblz/v1/model_base.rb

Class Method Summary collapse

Instance Method Summary collapse

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_mapObject



29
30
31
# File 'lib/bkblz/v1/model_base.rb', line 29

def to_map
  @map.dup
end

#to_sObject



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_yamlObject



33
34
35
# File 'lib/bkblz/v1/model_base.rb', line 33

def to_yaml
  @map.to_yaml
end