Class: Importable::Row
- Inherits:
-
Hash
- Object
- Hash
- Importable::Row
show all
- Defined in:
- lib/importable/row.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(data = {}) ⇒ Row
Returns a new instance of Row.
2
3
4
5
6
7
8
|
# File 'lib/importable/row.rb', line 2
def initialize(data={})
for k,v in data
self[k.to_sym] = v
end
create_case_insensitive_lookup!
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
10
11
12
13
|
# File 'lib/importable/row.rb', line 10
def method_missing(sym, *args, &block)
key = @case_insensitive_lookup[sym.to_s.downcase.to_sym]
self[key]
end
|
Class Method Details
.from_hash(hash) ⇒ Object
20
21
22
|
# File 'lib/importable/row.rb', line 20
def from_hash(hash)
self.new(hash)
end
|
.from_resource(resource) ⇒ Object
16
17
18
|
# File 'lib/importable/row.rb', line 16
def from_resource(resource)
self.new(resource.attributes)
end
|