Class: Noko::Record
- Inherits:
-
Object
show all
- Defined in:
- lib/noko/record.rb
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Record
4
5
6
|
# File 'lib/noko/record.rb', line 4
def initialize(attributes = {})
@attributes = attributes
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/noko/record.rb', line 20
def method_missing(name, *args, &block)
if @attributes.key?(name) && args.empty? && block.nil?
return @attributes[name]
else
super name, *args, &block
end
end
|
Instance Method Details
#[](name) ⇒ Object
8
9
10
|
# File 'lib/noko/record.rb', line 8
def [](name)
@attributes[name]
end
|
#[]=(name, value) ⇒ Object
12
13
14
|
# File 'lib/noko/record.rb', line 12
def []=(name, value)
@attributes[name] = value
end
|
#inspect ⇒ Object
16
17
18
|
# File 'lib/noko/record.rb', line 16
def inspect
'#<' + self.class.name + ' ' + @attributes.map { "#{_1}=#{_2.inspect}" }.join(', ') + '>'
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
28
29
30
|
# File 'lib/noko/record.rb', line 28
def respond_to_missing?(name, include_private = false)
@attributes.key?(name)
end
|
#to_h ⇒ Object
32
33
34
|
# File 'lib/noko/record.rb', line 32
def to_h
@attributes
end
|