class Representable::Config::Definitions
Stores Definitions from ::property. It preserves the adding order (1.9+). Same-named properties get overridden, just like in a Hash.
Overwrite #definition_class if you need a custom Definition object (helpful when using representable in other gems).
Attributes
definition_class[R]
Public Class Methods
new(definition_class)
click to toggle source
Calls superclass method
# File lib/representable/config.rb, line 25 def initialize(definition_class) @definition_class = definition_class super() end
Public Instance Methods
add(name, options, &block)
click to toggle source
# File lib/representable/config.rb, line 30 def add(name, options, &block) if options[:inherit] and parent_property = get(name) # i like that: the :inherit shouldn't be handled outside. return parent_property.merge!(options, &block) end options.delete(:inherit) # TODO: can we handle the :inherit in one single place? self[name.to_s] = definition_class.new(name, options, &block) end
get(name)
click to toggle source
# File lib/representable/config.rb, line 39 def get(name) self[name.to_s] end
remove(name)
click to toggle source
# File lib/representable/config.rb, line 43 def remove(name) delete(name.to_s) end