Class: Anoubis::Etc::Data

Inherits:
Object
  • Object
show all
Defined in:
app/controllers/anoubis/etc/data.rb

Overview

Class stores data information for current controller

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Data

Sets default basic system parameters



49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/anoubis/etc/data.rb', line 49

def initialize(options = {})
  self.data = nil
  self.fields = nil
  self.actions = nil
  self.parent = nil
  self.model = nil
  self.count = 0
  self.eager_load = []
  self.limit = 10
  self.offset = 0
  self.filter = nil
end

Instance Attribute Details

#actionsArray?

Returns current defined string array of table actions.

Returns:

  • (Array, nil)

    current defined string array of table actions.



18
# File 'app/controllers/anoubis/etc/data.rb', line 18

class_attribute :actions, default: nil

#countInteger

Returns (defaults to: 0) Specify the count of rows for defined data model.

Returns:

  • (Integer)

    (defaults to: 0) Specify the count of rows for defined data model



42
# File 'app/controllers/anoubis/etc/data.rb', line 42

class_attribute :count, default: 0

#dataActiveRecord?

Note:

Data is placed in this attribute when loaded from the model by actions ‘index’, ‘edit’, ‘update’, ‘create’ etc.

Returns current loaded data from the defined model or nil if data not loaded.

Returns:

  • (ActiveRecord, nil)

    current loaded data from the defined model or nil if data not loaded.



9
# File 'app/controllers/anoubis/etc/data.rb', line 9

class_attribute :data

#eager_loadArray

Returns (defaults to: []) Specify the current eager loaded models.

Returns:

  • (Array)

    (defaults to: []) Specify the current eager loaded models



30
# File 'app/controllers/anoubis/etc/data.rb', line 30

class_attribute :eager_load, default: []

#fieldsHash<Symbol, Field>?

Note:

Field’s options are placed in this attribute for actions ‘index’, ‘edit’, ‘update’, ‘create’ etc.

Returns current defined hash of model represented fields or nil if fields aren’t defined.

Returns:

  • (Hash<Symbol, Field>, nil)

    current defined hash of model represented fields or nil if fields aren’t defined



14
# File 'app/controllers/anoubis/etc/data.rb', line 14

class_attribute :fields, default: nil

#filterObject



45
# File 'app/controllers/anoubis/etc/data.rb', line 45

class_attribute :filter, default: nil

#limitInteger

Returns (defaults to: 10) Specify the total number of returned rows.

Returns:

  • (Integer)

    (defaults to: 10) Specify the total number of returned rows



34
# File 'app/controllers/anoubis/etc/data.rb', line 34

class_attribute :limit, default: 10

#modelActiveRecord

Returns (defaults to: nil) Specify the current ActiveRecord for controller (if exists).

Returns:

  • (ActiveRecord)

    (defaults to: nil) Specify the current ActiveRecord for controller (if exists)



26
# File 'app/controllers/anoubis/etc/data.rb', line 26

class_attribute :model, default: nil

#offsetInteger

Returns (defaults to: 0) Specify the default offset for rows were returned.

Returns:

  • (Integer)

    (defaults to: 0) Specify the default offset for rows were returned



38
# File 'app/controllers/anoubis/etc/data.rb', line 38

class_attribute :offset, default: 0

#parentActiveRecord

Returns (defaults to: nil) Specify the parent ActiveRecord for controller (if exists).

Returns:

  • (ActiveRecord)

    (defaults to: nil) Specify the parent ActiveRecord for controller (if exists)



22
# File 'app/controllers/anoubis/etc/data.rb', line 22

class_attribute :parent, default: nil

Instance Method Details

#to_hObject



75
76
77
78
79
80
81
82
83
84
85
86
# File 'app/controllers/anoubis/etc/data.rb', line 75

def to_h
  {
      fields: self.fields,
      model: self.model,
      eager_load: self.eager_load,
      count: self.count,
      limit: self.limit,
      offset: self.offset,
      actions: self.actions,
      parent: self.parent
  }
end