class Kojn::Model

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/kojn/model.rb, line 8
def initialize(attributes = {})
  self.attributes = attributes
end

Public Instance Methods

attributes() click to toggle source

Returns a hash with the current instance variables

# File lib/kojn/model.rb, line 27
def attributes
  Hash[instance_variables.map { |name| [name, instance_variable_get(name)] }]
end
attributes=(attributes = {}) click to toggle source

Set the attributes based on the given hash

# File lib/kojn/model.rb, line 16
def attributes=(attributes = {})
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    rescue NoMethodError => e
      puts "Unable to assign #{name}. No such method."
    end
  end
end