module Opto::Model::Initializer

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/opto/model/initializer.rb, line 7
def initialize(attributes = {})
  initialize_collection
  assign(attributes)
end

Public Instance Methods

assign(attributes) click to toggle source
# File lib/opto/model/initializer.rb, line 20
def assign(attributes)
  attributes.each do |key, value|
    if self.respond_to?("#{key}=")
      self.send("#{key}=", value)
    else
      raise ArgumentError, "Unknown attribute '#{key}'"
    end
  end
end
collection() click to toggle source
# File lib/opto/model/initializer.rb, line 16
def collection
  @collection
end
initialize_collection() click to toggle source
# File lib/opto/model/initializer.rb, line 12
def initialize_collection
  @collection = AttributeCollection.new(self.class.attribute_definitions)
end