class Nucleo::Models::Changes
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/changes.rb, line 11 def initialize(collection) @collection = Array(collection) end
Public Instance Methods
each(&block)
click to toggle source
# File lib/nucleo/models/changes.rb, line 15 def each(&block) internal_collection.each(&block) end
find_by_id(id)
click to toggle source
Retrieve a rule by the ID.
@return [Nucleo::Models::ChangeType]
# File lib/nucleo/models/changes.rb, line 26 def find_by_id(id) self.find { |record| record.id == id.to_s } end
push(args)
click to toggle source
# File lib/nucleo/models/changes.rb, line 19 def push(args) @collection.push(args) end
Private Instance Methods
internal_collection()
click to toggle source
# File lib/nucleo/models/changes.rb, line 31 def internal_collection core_collection = [] @collection.inject(core_collection) do |collection,record| const_name = ['nucleo', 'models', 'change_types', record['category'], record['type']].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