Class: Representable::Config
- Inherits:
-
Declarative::Definitions
- Object
- Declarative::Definitions
- Representable::Config
- Defined in:
- lib/representable/config.rb
Overview
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).
Instance Method Summary collapse
-
#options ⇒ Object
FIXME: this is not inherited.
- #remove(name) ⇒ Object
- #wrap=(value) ⇒ Object
-
#wrap_for(represented, *args, &block) ⇒ Object
Computes the wrap string or returns false.
Instance Method Details
#options ⇒ Object
FIXME: this is not inherited.
12 13 14 |
# File 'lib/representable/config.rb', line 12 def # FIXME: this is not inherited. @options ||= {} end |
#remove(name) ⇒ Object
8 9 10 |
# File 'lib/representable/config.rb', line 8 def remove(name) delete(name.to_s) end |
#wrap=(value) ⇒ Object
16 17 18 19 |
# File 'lib/representable/config.rb', line 16 def wrap=(value) value = value.to_s if value.is_a?(Symbol) @wrap = Uber::Options::Value.new(value) end |
#wrap_for(represented, *args, &block) ⇒ Object
Computes the wrap string or returns false.
22 23 24 25 26 27 28 29 |
# File 'lib/representable/config.rb', line 22 def wrap_for(represented, *args, &block) return unless @wrap value = @wrap.evaluate(represented, *args) return value if value != true infer_name_for(represented.class.name) end |