class Glassfrog::Base

Superclass of all GlassFrog classes.

Attributes

id[RW]

@return [Integer]

Public Class Methods

new(attrs = {}) { |self| ... } click to toggle source

Initializes a new Base object. @param attrs = {} [Hash] Attributes used to instantiate Base object.

@return [Glassfrog::Base] The new Base object.

# File lib/glassfrog/base.rb, line 17
def initialize(attrs = {})
  attrs.each do |key, value|
    instance_variable_set("@#{key}", value);
  end
  yield(self) if block_given?
end

Public Instance Methods

==(other) click to toggle source

Check equality between two objects. Should be equal if they are the same type and their IDs are also equal. @param other [Glassfrog::Base] The object to compare to self.

@return [Boolean] They are equal or not.

# File lib/glassfrog/base.rb, line 29
def ==(other)
  self.id == other.id && self.class == other.class
end
hashify() click to toggle source

Turns the Base object into a hash.

@return [Hash] Hash version of the Base object.

# File lib/glassfrog/base.rb, line 37
def hashify
  hash = Hash.new
  self.instance_variables.each { |var| hash[var.to_s.delete("@")] = self.instance_variable_get(var) }
  symbolize_keys(hash)
end