Class: Nucleo::Models::Feeds
- Inherits:
-
Object
- Object
- Nucleo::Models::Feeds
- Includes:
- Enumerable
- Defined in:
- lib/nucleo/models/feeds.rb
Class Method Summary collapse
-
.retrieve(site_id, params = {}) ⇒ Nucleo::Models::Feeds
Retrieve a feed with the specified params and return the model as an instance of Feeds.
Instance Method Summary collapse
-
#analytics_category ⇒ Array
Returns only the Analytics category items.
- #each(&block) ⇒ Object
-
#find_all_by_category_name(name) ⇒ Array
Returns all records that match the category name.
-
#find_all_by_site_id(id) ⇒ Array
Returns all records that match the site id.
-
#find_all_by_status_name(name) ⇒ Array
Returns all records that match the status name.
-
#find_all_by_type_name(name) ⇒ Array
Returns all records that match the type name.
-
#find_by_id(id) ⇒ Nucleo::Models::Feed?
Retrieve a record by the ID.
-
#initialize(collection) ⇒ Nucleo::Models::Feeds
constructor
Return an instance of the Feeds Collection domain model.
-
#page_context ⇒ Array
Returns only the page context items.
-
#sample(n) ⇒ Array
Delegate sample to the array.
-
#seo_category ⇒ Array
Returns only SEO category items.
-
#site_context ⇒ Array
REturns only the site context items.
Constructor Details
#initialize(collection) ⇒ Nucleo::Models::Feeds
Return an instance of the Feeds Collection domain model
14 15 16 |
# File 'lib/nucleo/models/feeds.rb', line 14 def initialize(collection) @collection = Array(collection) end |
Class Method Details
.retrieve(site_id, params = {}) ⇒ Nucleo::Models::Feeds
Retrieve a feed with the specified params and return the model as an instance of Feeds.
88 89 90 91 92 |
# File 'lib/nucleo/models/feeds.rb', line 88 def self.retrieve(site_id, params={}) response_body = Nucleo::Requests::Feed.retrieve(site_id, params) self.new(response_body) end |
Instance Method Details
#analytics_category ⇒ Array
Returns only the Analytics category items
35 36 37 |
# File 'lib/nucleo/models/feeds.rb', line 35 def analytics_category self.select(&:analytics_category?) end |
#each(&block) ⇒ Object
94 95 96 |
# File 'lib/nucleo/models/feeds.rb', line 94 def each(&block) internal_collection.each(&block) end |
#find_all_by_category_name(name) ⇒ Array
Returns all records that match the category name
63 64 65 |
# File 'lib/nucleo/models/feeds.rb', line 63 def find_all_by_category_name(name) self.select { |record| record.category_name == name.to_s } end |
#find_all_by_site_id(id) ⇒ Array
Returns all records that match the site id
56 57 58 |
# File 'lib/nucleo/models/feeds.rb', line 56 def find_all_by_site_id(id) self.select { |record| record.site_id == id.to_i } end |
#find_all_by_status_name(name) ⇒ Array
Returns all records that match the status name
77 78 79 |
# File 'lib/nucleo/models/feeds.rb', line 77 def find_all_by_status_name(name) self.select { |record| record.status_name == name.to_s } end |
#find_all_by_type_name(name) ⇒ Array
Returns all records that match the type name
70 71 72 |
# File 'lib/nucleo/models/feeds.rb', line 70 def find_all_by_type_name(name) self.select { |record| record.type_name == name.to_s } end |
#find_by_id(id) ⇒ Nucleo::Models::Feed?
Retrieve a record by the ID.
21 22 23 |
# File 'lib/nucleo/models/feeds.rb', line 21 def find_by_id(id) self.find { |record| record.id == id.to_s } end |
#page_context ⇒ Array
Returns only the page context items
42 43 44 |
# File 'lib/nucleo/models/feeds.rb', line 42 def page_context self.select(&:page_context?) end |
#sample(n) ⇒ Array
Delegate sample to the array
@todo: Ensure this delegates properly
103 104 105 |
# File 'lib/nucleo/models/feeds.rb', line 103 def sample(n) self.to_a.sample(n) end |
#seo_category ⇒ Array
Returns only SEO category items
28 29 30 |
# File 'lib/nucleo/models/feeds.rb', line 28 def seo_category self.select(&:seo_category?) end |
#site_context ⇒ Array
REturns only the site context items
49 50 51 |
# File 'lib/nucleo/models/feeds.rb', line 49 def site_context self.select(&:site_context?) end |