module Served::Resource::Attributable::ClassMethods
Public Instance Methods
attribute(name, options = {})
click to toggle source
declare an attribute for the resource
@example
class SomeResource attribute :attr1 end
@param name [Symbol] the name of the attribute
# File lib/served/resource/attributable.rb, line 20 def attribute(name, options = {}) return if attributes.include?(name) attributes[name] = options attr_accessor name end
attributes(*args)
click to toggle source
declare a set of attributes by name
@example
class SomeResource attributes :attr1, :attr2 end
@param *attributes [Array] a list of attributes for the resource @return [Hash] declared attributes for the resources
# File lib/served/resource/attributable.rb, line 35 def attributes(*args) args.each { |a| attribute a } unless args.empty? @attributes ||= {} end