Class: Block

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, items) ⇒ Block

Returns a new instance of Block.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/block.rb', line 5

def initialize(id, items)
  item = items[id]
  @id = id
  @content = item['content']
  @category = item['category']
  @entity = item['entity']
  @entity_association = item['entityAssociation']
  @entity_container = item['entityContainer']
  @attribute = item['attribute']
  @type = item['type']
  @association = item['association']
  @entity_clone = item['entityClone']
  @cloneable = item['cloneable']
  @clone_blocks = item['cloneChildren']
  @clone_parent = item['cloneParent'].to_s
  @sub_blocks = []
  item['subItemIds'].each do |sub_item_id|
    sub_item_id = sub_item_id.to_s
    @sub_blocks << Block.new(sub_item_id, items)
  end
end

Instance Attribute Details

#associationObject

Returns the value of attribute association.



2
3
4
# File 'lib/block.rb', line 2

def association
  @association
end

#attributeObject

Returns the value of attribute attribute.



2
3
4
# File 'lib/block.rb', line 2

def attribute
  @attribute
end

#categoryObject

Returns the value of attribute category.



2
3
4
# File 'lib/block.rb', line 2

def category
  @category
end

#clone_blocksObject

Returns the value of attribute clone_blocks.



2
3
4
# File 'lib/block.rb', line 2

def clone_blocks
  @clone_blocks
end

#clone_parentObject

Returns the value of attribute clone_parent.



2
3
4
# File 'lib/block.rb', line 2

def clone_parent
  @clone_parent
end

#cloneableObject

Returns the value of attribute cloneable.



2
3
4
# File 'lib/block.rb', line 2

def cloneable
  @cloneable
end

#contentObject

Returns the value of attribute content.



2
3
4
# File 'lib/block.rb', line 2

def content
  @content
end

#entityObject

Returns the value of attribute entity.



2
3
4
# File 'lib/block.rb', line 2

def entity
  @entity
end

#entity_associationObject

Returns the value of attribute entity_association.



2
3
4
# File 'lib/block.rb', line 2

def entity_association
  @entity_association
end

#entity_cloneObject

Returns the value of attribute entity_clone.



2
3
4
# File 'lib/block.rb', line 2

def entity_clone
  @entity_clone
end

#entity_containerObject

Returns the value of attribute entity_container.



2
3
4
# File 'lib/block.rb', line 2

def entity_container
  @entity_container
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/block.rb', line 2

def id
  @id
end

#sub_blocksObject

Returns the value of attribute sub_blocks.



2
3
4
# File 'lib/block.rb', line 2

def sub_blocks
  @sub_blocks
end

#typeObject

Returns the value of attribute type.



2
3
4
# File 'lib/block.rb', line 2

def type
  @type
end

Class Method Details

.allObject



27
28
29
# File 'lib/block.rb', line 27

def self.all
  ObjectSpace.each_object(self).to_a
end

.find(id) ⇒ Object



31
32
33
# File 'lib/block.rb', line 31

def self.find(id)
  all.find { |block| block.id == id }
end