Class: Anoubis::Etc::FieldOrder
- Inherits:
-
Object
- Object
- Anoubis::Etc::FieldOrder
- Defined in:
- app/controllers/anoubis/etc/field_order.rb
Overview
Definitions of fields order.
Instance Attribute Summary collapse
-
#default ⇒ Boolean
Defines if this field order by default.
-
#field ⇒ String, ...
Returns order field (or array of fields).
-
#order ⇒ Symbol
Field default order.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FieldOrder
constructor
Sets default parameters for field order.
-
#to_h ⇒ Hash
Generates hash representation of all class parameters,.
Constructor Details
#initialize(options = {}) ⇒ FieldOrder
Sets default parameters for field order
27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/anoubis/etc/field_order.rb', line 27 def initialize( = {}) self.default = false if .key? :default self.default = true if [:default].class == TrueClass end self.order = :asc if .key? :order self.order = :desc if [:order] == :desc || [:order].to_s.downcase == 'desc' end self.field = if .key? :field then [:field] else nil end end |
Instance Attribute Details
#default ⇒ Boolean
Defines if this field order by default.
19 |
# File 'app/controllers/anoubis/etc/field_order.rb', line 19 class_attribute :default, default: false |
#field ⇒ String, ...
Returns order field (or array of fields)
9 |
# File 'app/controllers/anoubis/etc/field_order.rb', line 9 class_attribute :field, default: nil |
#order ⇒ Symbol
Field default order.
14 |
# File 'app/controllers/anoubis/etc/field_order.rb', line 14 class_attribute :order, default: :asc |
Instance Method Details
#to_h ⇒ Hash
Generates hash representation of all class parameters,
42 43 44 45 46 47 48 |
# File 'app/controllers/anoubis/etc/field_order.rb', line 42 def to_h { field: self.field, order: self.order, default: self.default } end |