Module: PartComposition

Defined in:
lib/acts_as_page/part_composition.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/acts_as_page/part_composition.rb', line 8

def method_missing(name, *args)
  title = name.to_s.downcase.underscore
  if title.end_with?('=')
    return update_part(title, args.first)
  else
    part = find_part(title)
    if part
      return part.body
    else
      super(name, *args)
    end
  end
end

Class Method Details

.included(model_class) ⇒ Object



2
3
4
5
6
# File 'lib/acts_as_page/part_composition.rb', line 2

def self.included(model_class)
  model_class.class_eval do
    has_many :parts, class_name: 'PagePart'
  end
end