Method: Massimo::Site#resource

Defined in:
lib/massimo/site.rb

#resource(name_or_class, &block) ⇒ Object

Adds a new, custom resource to the Site. If a Class constant is given, it is added to directly to the #resources. If a Symbol or String is given, a new Class (inheriting from Massimo::Page) is created using that name with the given block used as the Class body.



35
36
37
38
39
40
41
42
43
# File 'lib/massimo/site.rb', line 35

def resource(name_or_class, &block)
  resource = case name_or_class
    when Class
      name_or_class
    else
      Object.const_set name_or_class.to_s.classify, Class.new(Massimo::Page, &block)
    end
  resources << resource
end