Module: Kuhsaft::BrickList

Included in:
Brick, ColumnBrick, Page, SliderBrick
Defined in:
lib/kuhsaft/brick_list.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
# File 'lib/kuhsaft/brick_list.rb', line 4

def self.included(base)
  def base.acts_as_brick_list
    self.has_many :bricks, :class_name => 'Kuhsaft::Brick', :dependent => :destroy, :as => :brick_list
  end
end

Instance Method Details

#collect_fulltextObject

Return relevant fulltext information for this brick (e.g: it’s name, description etc ).  It will be stored in the related Page. Implement how you see fit.



59
60
61
62
63
64
65
66
67
68
# File 'lib/kuhsaft/brick_list.rb', line 59

def collect_fulltext
  if respond_to?(:bricks)
    bricks.localized.inject('') do |text, brick|
      text << brick.collect_fulltext
      text
    end
  else
    ''
  end
end

#renders_own_childs?Boolean

When true, the brick must implement the rendering of its childs by itself by using the _childs partial When false, the default BrickList rendering is used See _brick_item partial

Returns:

  • (Boolean)


50
51
52
# File 'lib/kuhsaft/brick_list.rb', line 50

def renders_own_childs?
  false
end

#to_brick_item_idObject



10
11
12
# File 'lib/kuhsaft/brick_list.rb', line 10

def to_brick_item_id
  "brick-item-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}"
end

#to_brick_list_idObject



14
15
16
# File 'lib/kuhsaft/brick_list.rb', line 14

def to_brick_list_id
  "brick-list-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}"
end

#user_can_add_childs?Boolean

See TwoColumnBrick as an example, which can only have to ColumBricks and the User should not be able to add more

Returns:

  • (Boolean)


22
23
24
# File 'lib/kuhsaft/brick_list.rb', line 22

def user_can_add_childs?
  true
end

#user_can_delete?Boolean

return true if the user should be able to delete the brick through the UI. return false if not. See ColumnBrick, which should not be deleted inside the TwoColumnBrick

Returns:

  • (Boolean)


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

def user_can_delete?
  true
end

#user_can_save?Boolean

Return true if the user can hit the save button Return false if not See column brick, which has no data on its own except childs, therefore no button is needed

Returns:

  • (Boolean)


40
41
42
# File 'lib/kuhsaft/brick_list.rb', line 40

def user_can_save?
  true
end