Class: Nucleo::Models::Feeds

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/nucleo/models/feeds.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ Nucleo::Models::Feeds

Return an instance of the Feeds Collection domain model

Parameters:

  • collection (Array)


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.

Parameters:

  • site_id (String, Integer)

    The ID of the site for the feed

  • max_feed_items (Integer)

    Max number of feed items

Returns:



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_categoryArray

Returns only the Analytics category items

Returns:

  • (Array)


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

Returns:

  • (Array)


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

Returns:

  • (Array)


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

Returns:

  • (Array)


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

Returns:

  • (Array)


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.

Returns:



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_contextArray

Returns only the page context items

Returns:

  • (Array)


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

Returns:

  • (Array)


103
104
105
# File 'lib/nucleo/models/feeds.rb', line 103

def sample(n)
  self.to_a.sample(n)
end

#seo_categoryArray

Returns only SEO category items

Returns:

  • (Array)


28
29
30
# File 'lib/nucleo/models/feeds.rb', line 28

def seo_category
  self.select(&:seo_category?)
end

#site_contextArray

REturns only the site context items

Returns:

  • (Array)


49
50
51
# File 'lib/nucleo/models/feeds.rb', line 49

def site_context
  self.select(&:site_context?)
end