Module: ArrayOfHashSimpleDb
- Defined in:
- lib/array_of_hash_simple_db.rb,
lib/array_of_hash_simple_db/version.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
'0.1.0'
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
38 39 40 |
# File 'lib/array_of_hash_simple_db.rb', line 38 def attributes @attributes end |
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/array_of_hash_simple_db.rb', line 4 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#initialize(attributes) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/array_of_hash_simple_db.rb', line 40 def initialize(attributes) @attributes = attributes @attributes.each do |name, value| self.class.send(:define_method, name) do if @attributes.has_key?(name.to_s) @attributes[name.to_s] elsif @attributes.has_key?(name.to_sym) @attributes[name.to_sym] end end end end |