Module: Mokio::FrontendHelpers::ContentHelper
- Defined in:
- lib/mokio/frontend_helpers/content_helper.rb
Overview
Frontend helper methods contently used with Mokio models objects
Instance Method Summary collapse
-
#content_content(obj) ⇒ Object
Returns content field for given object as html.
-
#content_intro(obj) ⇒ Object
Returns intro field for given object as html.
-
#content_main_pic(obj, version = nil) ⇒ Object
Returns main picture for given object as html.
-
#content_title(obj) ⇒ Object
Returns title field for given object.
-
#isContent?(obj) ⇒ Boolean
Raises IsNotAMokioContentError if obj isn’t a Mokio::Content object.
-
#main_pic_url(obj, version = nil) ⇒ Object
Returns main picture url for given object as string.
Instance Method Details
#content_content(obj) ⇒ Object
Returns content field for given object as html
Attributes
-
obj
- Mokio::Content object (including inherited Mokio::Article etc..)
Exceptions
-
IsNotAMokioContentError
when obj is not a Mokio::Content object
62 63 64 65 |
# File 'lib/mokio/frontend_helpers/content_helper.rb', line 62 def content_content(obj) isContent?(obj) obj.content.html_safe end |
#content_intro(obj) ⇒ Object
Returns intro field for given object as html
Attributes
-
obj
- Mokio::Content object (including inherited Mokio::Article etc..)
Exceptions
-
IsNotAMokioContentError
when obj is not a Mokio::Content object
46 47 48 49 |
# File 'lib/mokio/frontend_helpers/content_helper.rb', line 46 def content_intro(obj) isContent?(obj) obj.intro.html_safe end |
#content_main_pic(obj, version = nil) ⇒ Object
Returns main picture for given object as html
Attributes
-
obj
- Mokio::Content object (including inherited Mokio::Article etc..) -
version
- Version of picture
Exceptions
-
IsNotAMokioContentError
when obj is not a Mokio::Content object
80 81 82 83 84 85 |
# File 'lib/mokio/frontend_helpers/content_helper.rb', line 80 def content_main_pic(obj, version = nil) isContent?(obj) html = "<img src='#{obj.main_pic.url}'></img>".html_safe unless version html ||= "<img src='#{obj.main_pic.url(version.to_sym)}'></img>" html.html_safe end |
#content_title(obj) ⇒ Object
Returns title field for given object
Attributes
-
obj
- Mokio::Content object (including inherited Mokio::Article etc..)
Exceptions
-
IsNotAMokioContentError
when obj is not a Mokio::Content object
29 30 31 32 |
# File 'lib/mokio/frontend_helpers/content_helper.rb', line 29 def content_title(obj) isContent?(obj) obj.title end |
#isContent?(obj) ⇒ Boolean
Raises IsNotAMokioContentError if obj isn’t a Mokio::Content object
Attributes
-
obj
- any object
14 15 16 |
# File 'lib/mokio/frontend_helpers/content_helper.rb', line 14 def isContent?(obj) raise Exceptions::IsNotAMokioContentError.new(obj) unless obj.is_a?(Mokio::Content) end |
#main_pic_url(obj, version = nil) ⇒ Object
Returns main picture url for given object as string
Attributes
-
obj
- Mokio::Content object (including inherited Mokio::Article etc..) -
version
- Version of picture
Exceptions
-
IsNotAMokioContentError
when obj is not a Mokio::Content object
99 100 101 102 103 104 |
# File 'lib/mokio/frontend_helpers/content_helper.rb', line 99 def main_pic_url(obj, version = nil) isContent?(obj) url = obj.main_pic.url unless version url ||= obj.main_pic.url(version.to_sym) url end |