Module: Served::Resource::Attributable::ClassMethods
- Defined in:
- lib/served/resource/attributable.rb
Defined Under Namespace
Modules: Prepend
Instance Method Summary collapse
-
#attribute(name, options = {}) ⇒ Object
declare an attribute for the resource.
-
#attributes(*args) ⇒ Hash
declare a set of attributes by name.
Instance Method Details
#attribute(name, options = {}) ⇒ Object
declare an attribute for the resource
20 21 22 23 24 |
# File 'lib/served/resource/attributable.rb', line 20 def attribute(name, = {}) return if attributes.include?(name) attributes[name] = attr_accessor name end |
#attributes(*args) ⇒ Hash
declare a set of attributes by name
35 36 37 38 |
# File 'lib/served/resource/attributable.rb', line 35 def attributes(*args) args.each { |a| attribute a } unless args.empty? @attributes ||= {} end |