Module: Representable::ClassMethods::Declarations

Defined in:
lib/representable.rb

Instance Method Summary collapse

Instance Method Details

#collection(name, options = {}, &block) ⇒ Object



107
108
109
110
# File 'lib/representable.rb', line 107

def collection(name, options={}, &block)
  options[:collection] = true # FIXME: don't override original.
  property(name, options, &block)
end

#hash(name = nil, options = {}, &block) ⇒ Object



112
113
114
115
116
117
# File 'lib/representable.rb', line 112

def hash(name=nil, options={}, &block)
  return super() unless name  # allow Object.hash.

  options[:hash] = true
  property(name, options, &block)
end

#property(name, options = {}, &block) ⇒ Object



103
104
105
# File 'lib/representable.rb', line 103

def property(name, options={}, &block)
  representable_attrs << definition_class.new(name, options)
end

#representable_attrsObject



95
96
97
# File 'lib/representable.rb', line 95

def representable_attrs
  @representable_attrs ||= build_config
end

#representation_wrap=(name) ⇒ Object



99
100
101
# File 'lib/representable.rb', line 99

def representation_wrap=(name)
  representable_attrs.wrap = name
end