Module: StewEucen::Acts::FertileForest::Table

Defined in:
lib/fertile_forest/saplings.rb,
lib/fertile_forest/modules/states.rb,
lib/fertile_forest/modules/configs.rb,
lib/fertile_forest/modules/finders.rb,
lib/fertile_forest/modules/utilities.rb,
lib/fertile_forest/modules/calculators.rb,
lib/fertile_forest/modules/reconstructers.rb

Overview

Name space of class methods for Fertile Forest

Defined Under Namespace

Modules: Calculators, Configs, Finders, Reconstructers, States, Utilities

Instance Method Summary collapse

Instance Method Details

#acts_as_fertile_forest(options = {}) ⇒ Object

Initializer for eech model.

Examples:

You write this method in a model of Rails as follows.

class Category < ActiveRecord::Base
  acts_as_fertile_forest
end

# When use alias name of columns as:
  acts_as_fertile_forest({
    aliases: {
      ff_queue:        :queue,
      ff_depth:        :depth,
      ff_grove:        :user_id,
      ff_soft_deleted: :deleted,
    }
  })

Parameters:

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

    Fertile Forest’s options.

Author:

  • StewEucen

Since:

  • Release 1.0.0



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/fertile_forest/saplings.rb', line 106

def acts_as_fertile_forest(options = {})
  # To use these modules in case fertile forest only.
  extend Configs
  extend Utilities
  extend Calculators
  extend Finders
  extend Reconstructers
  extend States

  # To change instance of ActiveRecord to Fertile Forest entity.
  include Entity

  ff_parse_options! options
  ff_resolve_alias_columns!

  # can set attr_accessor here
  attr_accessor :ff_kinship
  attr_accessor APPEND_BASE_ID_FIELD
  attr_accessor :ff_grove unless has_grove?

  ff_define_scopes!
  ff_define_alias_methods!
  ff_define_callbacks!
end