class Nucleo::Models::Checks
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/checks.rb, line 11 def initialize(collection) @collection = Array(collection) end
Public Instance Methods
each(&block)
click to toggle source
# File lib/nucleo/models/checks.rb, line 15 def each(&block) internal_collection.each(&block) end
find_by_type(type)
click to toggle source
Retrieve a check by type
@return [Nucleo::Models::ChangeType]
# File lib/nucleo/models/checks.rb, line 22 def find_by_type(type) self.find { |record| record.type == type } end
find_content()
click to toggle source
# File lib/nucleo/models/checks.rb, line 26 def find_content content = self.collect { |r| r.elements.find_content }.flatten.first return "" if content.blank? content end
find_image_src()
click to toggle source
# File lib/nucleo/models/checks.rb, line 33 def find_image_src self.collect { |r| r.elements.find_image_src }.flatten end
Private Instance Methods
internal_collection()
click to toggle source
# File lib/nucleo/models/checks.rb, line 38 def internal_collection core_collection = [] @collection.inject(core_collection) do |collection,record| begin const_name = ['nucleo', 'models', 'check_types', record['check']].map(&:camelcase).join('::') 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