Module: WingedCouch::Models::Attributes::ClassMethods

Defined in:
lib/winged_couch/models/attributes.rb

Overview

Module with class-methods for atributes defining

Instance Method Summary collapse

Instance Method Details

#attribute(attr_name, attr_klass, options = {}) ⇒ Object

Method for defining attribute

Parameters:

  • attr_name (Symbol)

    name of attribute

  • attr_klass (Class)

    class for type-casting

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :default (Object)

    default value of attribute


38
39
40
41
# File 'lib/winged_couch/models/attributes.rb', line 38

def attribute(attr_name, attr_klass, options = {})
  self._attributes << [attr_name, attr_klass, options]
  define_attribute(attr_name, attr_klass, options)
end

#attribute_namesArray

Returns attribute names

Returns:

  • (Array)

27
28
29
# File 'lib/winged_couch/models/attributes.rb', line 27

def attribute_names
  _attributes.map(&:first)
end

#inherited(klass) ⇒ Object


18
19
20
21
# File 'lib/winged_couch/models/attributes.rb', line 18

def inherited(klass)
  klass._attributes += _attributes
  super
end