Class: Leeno::Model::History

Inherits:
Base
  • Object
show all
Defined in:
lib/leeno/model/history.rb

Constant Summary collapse

FIELDS =
[
   :canvas_id,
   :history_id,
   :parent_id,
   :image_large,
   :image_small,
   :image_thumb,
   :create_date,
   :update_date
]

Instance Method Summary collapse

Methods inherited from Base

#exclude_options!, #exclude_options?, #include_options!, #to_json

Constructor Details

#initialize(data = {}) ⇒ History

Returns a new instance of History.



15
16
17
18
19
20
# File 'lib/leeno/model/history.rb', line 15

def initialize data={}
  super(data)
  @canvas   = Model::Canvas.new(data["canvas"])  unless data["canvas"].nil?
  @parent   = Model::History.new(data["parent"]) unless data["parent"].nil?
  @children = Leeno::Array.new(data["children"].map{|h|Model::History.new(h)}) unless data["children"].nil?
end

Instance Method Details

#canvasObject



22
23
24
# File 'lib/leeno/model/history.rb', line 22

def canvas
  @canvas ||= Api::Canvas.find(canvas_id)
end

#childrenObject



31
32
33
# File 'lib/leeno/model/history.rb', line 31

def children
  @children ||= Leeno::Array.new(Api::History.find(canvas_id, history_id).children)
end

#parentObject



26
27
28
29
# File 'lib/leeno/model/history.rb', line 26

def parent
  return nil if (parent_id.nil? || parent_id.to_i == 0)
  @parent ||= Api::History.find(canvas_id, parent_id)
end