class CapicuaGen::AttributeMixer
Clase que permite un escalonamiento de propidades de forma que un AttributeMixer
puede estar dentro de otro (recursivamente) y permitir acceder a cualquier atributo definido en cualquiera de ellos, permitiendo que se sobreescriban.
Attributes
mixer_base[RW]
Mezclador de la base
Public Class Methods
new()
click to toggle source
# File lib/CapicuaGen/attribute_mixer.rb, line 35 def initialize @internal_mixer= {} @mixer_base = nil end
Public Instance Methods
[](key)
click to toggle source
Recuperamos un valor
# File lib/CapicuaGen/attribute_mixer.rb, line 41 def [](key) return @internal_mixer[key] if @internal_mixer[key] return @mixer_base[key] if @mixer_base return nil end
[]=(key, value)
click to toggle source
agregamos un valor
# File lib/CapicuaGen/attribute_mixer.rb, line 57 def []= (key, value) @internal_mixer[key]= value end
add(hash={})
click to toggle source
AƱade un hash de valores
# File lib/CapicuaGen/attribute_mixer.rb, line 49 def add(hash={}) hash.each_pair do |k, v| self[k]=v end end
has_in_base?(attribute)
click to toggle source
Indica que un attribute esta definido en la base
# File lib/CapicuaGen/attribute_mixer.rb, line 62 def has_in_base?(attribute) return false unless @mixer_base return true if @mixer_base.has_in_self?(attribute) return @mixer_base.has_in_base?(attribute) end
has_in_self?(attribute)
click to toggle source
Indica que un attribute esta definido en el objeto mismo
# File lib/CapicuaGen/attribute_mixer.rb, line 69 def has_in_self?(attribute) return false unless @internal_mixer return (@internal_mixer.has_key?(attribute) and @internal_mixer[attribute]) end