Class: Representable::Config
- Includes:
- InheritMethods, InheritableArray
- Defined in:
- lib/representable/config.rb
Overview
NOTE: the API of Config is subject to change so don’t rely too much on this private object.
Defined Under Namespace
Modules: InheritMethods, InheritableArray
Instance Method Summary collapse
- #<<(definition) ⇒ Object
- #[](name) ⇒ Object
- #each(*args, &block) ⇒ Object
-
#options ⇒ Object
Write representer configuration into this hash.
- #wrap=(value) ⇒ Object
-
#wrap_for(name, context, *args) ⇒ Object
Computes the wrap string or returns false.
Methods included from InheritableArray
#inherit, #inheritable_array, #inheritable_arrays
Methods included from InheritMethods
Methods included from Hash
#from_hash, included, #to_hash
Instance Method Details
#<<(definition) ⇒ Object
22 23 24 |
# File 'lib/representable/config.rb', line 22 def <<(definition) self[definition.name] = definition end |
#[](name) ⇒ Object
26 27 28 |
# File 'lib/representable/config.rb', line 26 def [](name) fetch(name.to_s, nil) end |
#each(*args, &block) ⇒ Object
30 31 32 |
# File 'lib/representable/config.rb', line 30 def each(*args, &block) values.each(*args, &block) end |
#options ⇒ Object
Write representer configuration into this hash.
50 51 52 |
# File 'lib/representable/config.rb', line 50 def @options ||= {} end |
#wrap=(value) ⇒ Object
34 35 36 37 |
# File 'lib/representable/config.rb', line 34 def wrap=(value) value = value.to_s if value.is_a?(Symbol) @wrap = Uber::Options::Value.new(value) end |
#wrap_for(name, context, *args) ⇒ Object
Computes the wrap string or returns false.
40 41 42 43 44 45 46 47 |
# File 'lib/representable/config.rb', line 40 def wrap_for(name, context, *args) return unless @wrap value = @wrap.evaluate(context, *args) return infer_name_for(name) if value === true value end |