class Nucleo::Models::Elements
Public Class Methods
new(collection)
click to toggle source
Return an instance of the Rules collection domain model
@param collection [Array]
@return [Nucleo::Models::Changes]
# File lib/nucleo/models/elements.rb, line 11 def initialize(collection) @collection = Array(collection) end
Public Instance Methods
each(&block)
click to toggle source
# File lib/nucleo/models/elements.rb, line 15 def each(&block) internal_collection.each(&block) end
find_content()
click to toggle source
# File lib/nucleo/models/elements.rb, line 19 def find_content self.collect { |r| r.content if r.content_present? } end
find_image_src()
click to toggle source
# File lib/nucleo/models/elements.rb, line 23 def find_image_src self.collect { |r| r.image_src if r.image? } end
Private Instance Methods
internal_collection()
click to toggle source
# File lib/nucleo/models/elements.rb, line 28 def internal_collection core_collection = [] @collection.inject(core_collection) do |collection,record| const_name = ['nucleo', 'models', 'element'].map(&:camelcase).join('::') begin collection.push(Object.const_get(const_name).new(record)) rescue Nucleo::Client.configuration.logger.fatal("Could not instantiate: %s" % [const_name]) end collection end Array(core_collection) end