Class: Nucleo::Models::FeedTypes::Base
- Inherits:
-
Object
- Object
- Nucleo::Models::FeedTypes::Base
- Includes:
- Comparable
- Defined in:
- lib/nucleo/models/feed_types/base.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Sort by the executed at attribute.
-
#analytics_category? ⇒ Boolean
Returns true if this is for analytics.
-
#category ⇒ String
(also: #category_name)
Returns the Category of the recommendation.
-
#children ⇒ Nucleo::Models::Feeds
(also: #issues)
Return the child recommendations.
-
#children? ⇒ Boolean
(also: #issues?)
Returns true if there are children.
-
#context ⇒ String
(also: #context_name)
Returns the Context of the recommendation.
-
#executed_at ⇒ DateTime?
Return the time of execution of this recommendation.
-
#id ⇒ String
Return the ID of this recommendation.
-
#initialize(attributes = {}) ⇒ Nucleo::Models::Feed
constructor
Return an instance of the Feed domain model.
-
#page ⇒ Nucleo::Models::Page?
Returns the page, if present.
-
#page? ⇒ Boolean
Returns true if there is an attached page.
-
#page_context? ⇒ Boolean
Returns true if this is a page context.
-
#page_recommendation_id ⇒ String
Returns the page recommendation ID.
-
#record_id ⇒ String
Return the record ID.
-
#seo_category? ⇒ Boolean
Returns true if this is for seo.
-
#site_analytic_id ⇒ String
Returns the site analytic ID.
-
#site_context? ⇒ Boolean
Returns true if this is a site context.
-
#site_id ⇒ Integer
Returns the ID of the site.
-
#status ⇒ String
(also: #status_name)
Returns the Status of the recommendation.
-
#type ⇒ String
(also: #type_name)
Returns the Type of the recommendation.
Constructor Details
#initialize(attributes = {}) ⇒ Nucleo::Models::Feed
Return an instance of the Feed domain model
14 15 16 |
# File 'lib/nucleo/models/feed_types/base.rb', line 14 def initialize(attributes={}) @attributes = attributes end |
Instance Method Details
#<=>(other) ⇒ Object
Sort by the executed at attribute
19 20 21 |
# File 'lib/nucleo/models/feed_types/base.rb', line 19 def <=>(other) self.executed_at <=> other.executed_at end |
#analytics_category? ⇒ Boolean
Returns true if this is for analytics
137 138 139 |
# File 'lib/nucleo/models/feed_types/base.rb', line 137 def analytics_category? 'analytics' == self.category end |
#category ⇒ String Also known as: category_name
Returns the Category of the recommendation
@todo: Create a Category model that can handle answering some basic questions.
87 88 89 |
# File 'lib/nucleo/models/feed_types/base.rb', line 87 def category @attributes['category'] end |
#children ⇒ Nucleo::Models::Feeds Also known as: issues
Return the child recommendations
158 159 160 |
# File 'lib/nucleo/models/feed_types/base.rb', line 158 def children Nucleo::Models::Feeds.new(children_collection) end |
#children? ⇒ Boolean Also known as: issues?
Returns true if there are children
166 167 168 |
# File 'lib/nucleo/models/feed_types/base.rb', line 166 def children? self.children.any? end |
#context ⇒ String Also known as: context_name
Returns the Context of the recommendation
111 112 113 |
# File 'lib/nucleo/models/feed_types/base.rb', line 111 def context @attributes['context'] end |
#executed_at ⇒ DateTime?
Return the time of execution of this recommendation
119 120 121 122 123 124 125 |
# File 'lib/nucleo/models/feed_types/base.rb', line 119 def executed_at begin DateTime.parse(@attributes['executed_at']) rescue nil end end |
#id ⇒ String
Return the ID of this recommendation
70 71 72 |
# File 'lib/nucleo/models/feed_types/base.rb', line 70 def id (self.page_recommendation_id || self.site_analytic_id || self.record_id) end |
#page ⇒ Nucleo::Models::Page?
Returns the page, if present
@note: We have to inject the ID back in as it’s not present in the ‘page` response.
29 30 31 32 33 34 35 |
# File 'lib/nucleo/models/feed_types/base.rb', line 29 def page value = @attributes['page'] return nil if value.nil? || value.empty? Nucleo::Models::Page.new(value) end |
#page? ⇒ Boolean
Returns true if there is an attached page
40 41 42 |
# File 'lib/nucleo/models/feed_types/base.rb', line 40 def page? !self.page.nil? end |
#page_context? ⇒ Boolean
Returns true if this is a page context
144 145 146 |
# File 'lib/nucleo/models/feed_types/base.rb', line 144 def page_context? 'page' == self.context end |
#page_recommendation_id ⇒ String
Returns the page recommendation ID
47 48 49 |
# File 'lib/nucleo/models/feed_types/base.rb', line 47 def page_recommendation_id @attributes['page_recommendation_id'] end |
#record_id ⇒ String
Return the record ID
@note: This is to support instantiation from ‘children`
63 64 65 |
# File 'lib/nucleo/models/feed_types/base.rb', line 63 def record_id @attributes['id'] end |
#seo_category? ⇒ Boolean
Returns true if this is for seo
130 131 132 |
# File 'lib/nucleo/models/feed_types/base.rb', line 130 def seo_category? 'seo' == self.category end |
#site_analytic_id ⇒ String
Returns the site analytic ID
54 55 56 |
# File 'lib/nucleo/models/feed_types/base.rb', line 54 def site_analytic_id @attributes['site_analytic_id'] end |
#site_context? ⇒ Boolean
Returns true if this is a site context
151 152 153 |
# File 'lib/nucleo/models/feed_types/base.rb', line 151 def site_context? 'site' == self.context end |
#site_id ⇒ Integer
Returns the ID of the site
77 78 79 |
# File 'lib/nucleo/models/feed_types/base.rb', line 77 def site_id @attributes['site_id'] end |
#status ⇒ String Also known as: status_name
Returns the Status of the recommendation
103 104 105 |
# File 'lib/nucleo/models/feed_types/base.rb', line 103 def status @attributes['status'] end |
#type ⇒ String Also known as: type_name
Returns the Type of the recommendation
95 96 97 |
# File 'lib/nucleo/models/feed_types/base.rb', line 95 def type @attributes['type'] end |