Class: TracksAttributes::Base

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods
Includes:
ActiveModel::Validations
Defined in:
lib/tracks_attributes/base.rb

Overview

TracksAttributes::Base is a convienience class that offers the basic services available through the TracksAttribute module for plain old ruby objects.

  • it tracks attributes

  • it provides Base::create to enable re-hydration within the scope of a containing class that is being built from JSON or XML

  • it includes ActiveModel::Validations

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

tracks_attributes

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ Base

The default :initialize method needed by a class that implements TracksAttributes during re-hydration.

as instance variables.

Parameters:

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

    is Hash with attributes as values to set

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

    to be passed onto the initialize method.



37
38
39
# File 'lib/tracks_attributes/base.rb', line 37

def initialize(attributes = {}, options = {})
  self.all_attributes = attributes
end

Class Method Details

.create(attributes = {}, options = {}) ⇒ Object

The standard create class method needed by a class that implements TracksAttributes during re-hydration.

as instance variables.

Parameters:

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

    is Hash with attributes as values to set

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

    to be passed onto the initialize method.



25
26
27
# File 'lib/tracks_attributes/base.rb', line 25

def self.create(attributes = {}, options = {})
  self.new attributes, options
end