Class: Representable::Config

Inherits:
Hash
  • Object
show all
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 Attribute Summary collapse

Instance Method Summary collapse

Methods included from InheritableArray

#inherit, #inheritable_array, #inheritable_arrays

Methods included from InheritMethods

#cloned, #inherit

Methods included from Hash

#from_hash, included, #to_hash

Instance Attribute Details

#wrapObject

Returns the value of attribute wrap.



34
35
36
# File 'lib/representable/config.rb', line 34

def wrap
  @wrap
end

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

#optionsObject

Write representer configuration into this hash.



44
45
46
# File 'lib/representable/config.rb', line 44

def options
  @options ||= {}
end

#wrap_for(name) ⇒ Object

Computes the wrap string or returns false.



37
38
39
40
41
# File 'lib/representable/config.rb', line 37

def wrap_for(name)
  return unless wrap
  return infer_name_for(name) if wrap === true
  wrap
end