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?



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

class_attribute :actions, default: nil

#countInteger



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.



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

class_attribute :data

#eager_loadArray



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.



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



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

class_attribute :limit, default: 10

#modelActiveRecord



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

class_attribute :model, default: nil

#offsetInteger



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

class_attribute :offset, default: 0

#parentActiveRecord



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