Class: MegaBar::Layout

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mega_bar/layout.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_nameObject

Returns the value of attribute base_name.



16
17
18
# File 'app/models/mega_bar/layout.rb', line 16

def base_name
  @base_name
end

#block_textObject

Returns the value of attribute block_text.



16
17
18
# File 'app/models/mega_bar/layout.rb', line 16

def block_text
  @block_text
end

#make_blockObject

Returns the value of attribute make_block.



16
17
18
# File 'app/models/mega_bar/layout.rb', line 16

def make_block
  @make_block
end

#model_idObject

Returns the value of attribute model_id.



16
17
18
# File 'app/models/mega_bar/layout.rb', line 16

def model_id
  @model_id
end

Instance Method Details

#create_layable_sectionsObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/models/mega_bar/layout.rb', line 22

def create_layable_sections
  template = Template.find(self.template_id)
  template.template_sections.each do |section|
    if section.code_name == 'main'
      layout_section_hash = { code_name: self.base_name + '_' + section.code_name, block_text: self.block_text, model_id: self.model_id, base_name: self.base_name}
    else
      layout_section_hash = { code_name: self.base_name + '_' + section.code_name, block_text: self.block_text, base_name: self.base_name}
    end
    ls = LayoutSection.create(layout_section_hash)
    layable = Layable.create(layout_section_id: ls.id, template_section_id: section.id, layout_id: self.id)
  end
end