Class: Dupe::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/dupe/record.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Record

Returns a new instance of Record.



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/dupe/record.rb', line 3

def initialize(hash)
  @attributes = hash.merge(hash) do |k,v| 
    if v.is_a?(Hash) 
      Record.new(v)
    elsif v.is_a?(Array)
      v.map {|r| Record.new(r)}
    else
      v
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



15
16
17
# File 'lib/dupe/record.rb', line 15

def method_missing(method_name, *args, &block)
  @attributes[method_name.to_sym]
end