Class: Datagrid::Filters::DynamicFilter::FilterValue
- Inherits:
-
Object
- Object
- Datagrid::Filters::DynamicFilter::FilterValue
- Defined in:
- lib/datagrid/filters/dynamic_filter.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#operation ⇒ Object
Returns the value of attribute operation.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(grid_class, object = nil) ⇒ FilterValue
constructor
A new instance of FilterValue.
- #inspect ⇒ Object
- #to_a ⇒ Object
- #to_ary ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(grid_class, object = nil) ⇒ FilterValue
Returns a new instance of FilterValue.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 106 def initialize(grid_class, object = nil) super() case object when Hash object = object.symbolize_keys self.field = object[:field] self.operation = object[:operation] self.value = object[:value] when Array self.field = object[0] self.operation = object[1] self.value = object[2] else raise ArgumentError, object.inspect end return unless grid_class type = grid_class.driver.normalized_column_type( grid_class.scope, field, ) self.value = type_cast(type, value) end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
104 105 106 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 104 def field @field end |
#operation ⇒ Object
Returns the value of attribute operation.
104 105 106 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 104 def operation @operation end |
#value ⇒ Object
Returns the value of attribute value.
104 105 106 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 104 def value @value end |
Instance Method Details
#inspect ⇒ Object
130 131 132 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 130 def inspect { field: field, operation: operation, value: value } end |
#to_a ⇒ Object
138 139 140 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 138 def to_a [field, operation, value] end |
#to_ary ⇒ Object
134 135 136 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 134 def to_ary to_a end |
#to_h ⇒ Object
142 143 144 |
# File 'lib/datagrid/filters/dynamic_filter.rb', line 142 def to_h { field: field, operation: operation, value: value } end |