Class: Anoubis::Etc::Model
- Inherits:
-
Object
- Object
- Anoubis::Etc::Model
- Defined in:
- app/controllers/anoubis/etc/model.rb
Overview
Definitions of model options. Class is used for define attached model.
Instance Attribute Summary collapse
-
#model ⇒ ActiveRecord
Defines model class.
-
#order ⇒ Boolean
Field name is used for defines order field when data selected from model.
-
#select ⇒ String
Special select parameters.
-
#title ⇒ Symbol
Field name is used for defines title when data selected from model.
-
#updated_at ⇒ Number
Timestamp of last changes in the model.
-
#where ⇒ Hash
Where parameters are used when data selected from model.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Model
constructor
Sets default parameters for field.
-
#to_h ⇒ Hash
Generates hash representation of all class parameters,.
Constructor Details
#initialize(options = {}) ⇒ Model
Sets default parameters for field
44 45 46 47 48 49 50 51 |
# File 'app/controllers/anoubis/etc/model.rb', line 44 def initialize( = {}) self.model = [:model] self.title = if .key? :title then [:title] else :title end self.order = if .key? :order then [:order] else self.title end self.where = if .key? :where then [:where] else {} end self.select = if .key? :select then [:select] else nil end self.updated_at = 0 end |
Instance Attribute Details
#model ⇒ ActiveRecord
Defines model class. This field is required.
9 |
# File 'app/controllers/anoubis/etc/model.rb', line 9 class_attribute :model, default: nil |
#order ⇒ Boolean
Field name is used for defines order field when data selected from model. By default uses field daefined as (#title)
20 |
# File 'app/controllers/anoubis/etc/model.rb', line 20 class_attribute :order, default: :title |
#select ⇒ String
Special select parameters.
30 |
# File 'app/controllers/anoubis/etc/model.rb', line 30 class_attribute :select, default: nil |
#title ⇒ Symbol
Field name is used for defines title when data selected from model.
14 |
# File 'app/controllers/anoubis/etc/model.rb', line 14 class_attribute :title, default: :title |
#updated_at ⇒ Number
Timestamp of last changes in the model.
35 |
# File 'app/controllers/anoubis/etc/model.rb', line 35 class_attribute :updated_at, default: {} |
#where ⇒ Hash
Where parameters are used when data selected from model.
25 |
# File 'app/controllers/anoubis/etc/model.rb', line 25 class_attribute :where, default: {} |
Instance Method Details
#to_h ⇒ Hash
Generates hash representation of all class parameters,
56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/anoubis/etc/model.rb', line 56 def to_h { model: self.model, title: self.title, order: self.order, where: self.where, updated_at: self.updated_at } end |