Class: Lol::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/lol/model.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Lol::Model

Initializes a Lol::Model

Parameters:

  • options (Hash) (defaults to: {})


12
13
14
15
16
17
# File 'lib/lol/model.rb', line 12

def initialize options = {}
  @raw = options
  options.each do |attribute_name, value|
    send "#{attribute_name.to_s.underscore}=", value
  end
end

Instance Attribute Details

#rawHash (readonly)

Returns raw version of options Hash used to initialize Model.

Returns:

  • (Hash)

    raw version of options Hash used to initialize Model



7
8
9
# File 'lib/lol/model.rb', line 7

def raw
  @raw
end

Instance Method Details

#inspectString

Re-written Object#inspect to skip the @raw instance variable

Returns:

  • (String)

    representation of object



21
22
23
24
25
26
# File 'lib/lol/model.rb', line 21

def inspect
  vars = self.instance_variables.
    select {|v| v != :@raw}.
    map{|v| "#{v}=#{instance_variable_get(v).inspect}"}.join(", ")
  "<#{self.class}: #{vars}>"
end