Class: Block

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

Direct Known Subclasses

StaticContentBlock, Widget

Instance Method Summary collapse

Instance Method Details

#cloneObject



29
30
31
32
33
34
35
36
# File 'app/models/block.rb', line 29

def clone
  cloned = super
  cloned.translations = translations.clone unless translations.empty?
  %w(page_col_ids category_ids).each do |method|
    cloned.send("#{method}=",self.send(method))
  end
  return cloned
end


46
47
48
49
# File 'app/models/block.rb', line 46

def link_with(page)
  page.blocks << self
  page.blocks.reset_positions
end

#linked_with?(page) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/block.rb', line 42

def linked_with?(page)
  self.pages.include?(page)
end

#pagesObject



38
39
40
# File 'app/models/block.rb', line 38

def pages
  self.page_cols.map(&:page)
end


51
52
53
54
# File 'app/models/block.rb', line 51

def unlink_with(page)
  page.blocks.delete self
  page.blocks.reset_positions
end