class Camdram::Base

Attributes

id[R]

Public Class Methods

new(options = {}) click to toggle source

Instantiate a new object from a JSON hash

@param options [Hash] A single JSON hash with symbolized keys. @return [Object] The new object.

# File lib/camdram/base.rb, line 11
def initialize(options = {})
  set_from_hash(options)
end

Private Instance Methods

set_from_hash(options) click to toggle source

Sets the object's instance variables from a JSON hash

@param options [Hash] A single JSON hash with symbolized keys.

# File lib/camdram/base.rb, line 20
def set_from_hash(options)
  options.each do |key, value|
    # Only set the instance variable if the class or sub-class
    # has an associated attr_accessor for that variable
    instance_variable_set("@#{key}", value) if self.respond_to?(key)
  end
end