Class: PartialKs::FilteredTable
- Inherits:
-
Object
- Object
- PartialKs::FilteredTable
- Defined in:
- lib/partial_ks/filtered_table.rb
Instance Attribute Summary collapse
-
#custom_filter_relation ⇒ Object
readonly
Returns the value of attribute custom_filter_relation.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#table ⇒ Object
readonly
Returns the value of attribute table.
Instance Method Summary collapse
-
#initialize(model, parent, custom_filter_relation: nil) ⇒ FilteredTable
constructor
A new instance of FilteredTable.
- #to_sql ⇒ Object
Constructor Details
#initialize(model, parent, custom_filter_relation: nil) ⇒ FilteredTable
Returns a new instance of FilteredTable.
6 7 8 9 10 |
# File 'lib/partial_ks/filtered_table.rb', line 6 def initialize(model, parent, custom_filter_relation: nil) @table = PartialKs::Table.new(model) @parent = parent @custom_filter_relation = custom_filter_relation end |
Instance Attribute Details
#custom_filter_relation ⇒ Object (readonly)
Returns the value of attribute custom_filter_relation.
3 4 5 |
# File 'lib/partial_ks/filtered_table.rb', line 3 def custom_filter_relation @custom_filter_relation end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
3 4 5 |
# File 'lib/partial_ks/filtered_table.rb', line 3 def parent @parent end |
#table ⇒ Object (readonly)
Returns the value of attribute table.
3 4 5 |
# File 'lib/partial_ks/filtered_table.rb', line 3 def table @table end |
Instance Method Details
#to_sql ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/partial_ks/filtered_table.rb', line 12 def to_sql if custom_filter_relation filter_based_on_custom_filter_relation elsif parent && parent.to_sql.nil? nil elsif parent filter_based_on_parent_model(parent.table.model) else nil end end |