Class: SemiStatic::Page
- Inherits:
-
Object
- Object
- SemiStatic::Page
- Extended by:
- ActiveModel::Naming
- Includes:
- ActiveModel::Conversion
- Defined in:
- lib/semi_static/page.rb
Defined Under Namespace
Modules: WithLocale
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
- #slug ⇒ Object
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(body, args) ⇒ Page
constructor
A new instance of Page.
- #persisted? ⇒ Boolean
- #render(source) ⇒ Object
- #to_param ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(body, args) ⇒ Page
26 27 28 29 30 31 |
# File 'lib/semi_static/page.rb', line 26 def initialize(body, args) @body = body args.each_pair do |k,v| send("#{k}=", v) end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
10 11 12 |
# File 'lib/semi_static/page.rb', line 10 def body @body end |
#slug ⇒ Object
37 38 39 |
# File 'lib/semi_static/page.rb', line 37 def slug @slug || title.to_slug.normalize.to_s.gsub("!", "") end |
#title ⇒ Object
Returns the value of attribute title.
10 11 12 |
# File 'lib/semi_static/page.rb', line 10 def title @title end |
Class Method Details
.all ⇒ Object
13 14 15 |
# File 'lib/semi_static/page.rb', line 13 def self.all SemiStatic.backend.all(self) end |
.find(param) ⇒ Object
21 22 23 24 |
# File 'lib/semi_static/page.rb', line 21 def self.find(param) param = CGI.unescape(param) if param =~ /%/ all.find {|a| a.to_param == param } end |
.first ⇒ Object
17 18 19 |
# File 'lib/semi_static/page.rb', line 17 def self.first all.first end |
Instance Method Details
#persisted? ⇒ Boolean
49 50 51 |
# File 'lib/semi_static/page.rb', line 49 def persisted? true end |
#render(source) ⇒ Object
45 46 47 |
# File 'lib/semi_static/page.rb', line 45 def render(source) body.render(source).html_safe end |
#to_param ⇒ Object
33 34 35 |
# File 'lib/semi_static/page.rb', line 33 def to_param slug end |
#to_s ⇒ Object
41 42 43 |
# File 'lib/semi_static/page.rb', line 41 def to_s title.to_s end |