Module: Hoodoo::ActiveRecord::Translated

Defined in:
lib/hoodoo/active/active_record/translated.rb

Overview

Support mixin for models subclassed from ActiveRecord::Base providing as-per-API-standard internationalisation support. See Hoodoo::ActiveRecord::Translated::ClassMethods#translated for details.

See also:

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Class Method Details

.included(model) ⇒ Object

Instantiates this module when it is included.

Example:

class SomeModel < ActiveRecord::Base
  include Hoodoo::ActiveRecord::Translated
  # ...
end
model

The ActiveRecord::Base descendant that is including this module.



36
37
38
39
40
41
42
43
44
45
# File 'lib/hoodoo/active/active_record/translated.rb', line 36

def self.included( model )
  model.class_attribute(
    :nz_co_loyalty_hoodoo_translate_with,
    :instance_predicate => false,
    :instance_accessor  => false
  )

  instantiate( model ) unless model == Hoodoo::ActiveRecord::Base
  super( model )
end

.instantiate(model) ⇒ Object

When instantiated in an ActiveRecord::Base subclass, all of the Hoodoo::ActiveRecord::Translated::ClassMethods methods are defined as class methods on the including class.

model

The ActiveRecord::Base descendant that is including this module.



54
55
56
# File 'lib/hoodoo/active/active_record/translated.rb', line 54

def self.instantiate( model )
  model.extend( ClassMethods )
end