Class: Lore::Attribute_Hash

Inherits:
Hash show all
Defined in:
lib/lore/model/model_instance.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Hash

#deep_merge!, #keys_flat, #merge_nested_hash!, #nested_hash

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key) ⇒ Object



34
35
36
# File 'lib/lore/model/model_instance.rb', line 34

def method_missing(key) 
  self[key] 
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/lore/model/model_instance.rb', line 14

def [](key)
  if !random_access_op(key).nil? then
    return random_access_op(key)
  elsif !random_access_op(key.to_s).nil? then
    return random_access_op(key.to_s)
  else
    return random_access_op(key.to_s[0..24].to_sym) 
  end
end

#[]=(key, value) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/lore/model/model_instance.rb', line 24

def []=(key, value)
  begin
    key = key.to_s[0..24].to_sym
  rescue ::Exception => excep
    Lore.logger.debug { 'Error when trying to access attribute ' << key.inspect }
    raise excep
  end
  self.random_access_assign_op(key, value)
end

#random_access_assign_opObject



13
# File 'lib/lore/model/model_instance.rb', line 13

alias random_access_assign_op []=

#random_access_opObject



12
# File 'lib/lore/model/model_instance.rb', line 12

alias random_access_op []