Module: Fae::BaseModelConcern::ClassMethods
- Defined in:
- app/models/concerns/fae/base_model_concern.rb
Instance Method Summary collapse
- #filter(params) ⇒ Object
- #filter_all ⇒ Object
- #for_fae_index ⇒ Object
- #order_method ⇒ Object
- #to_csv ⇒ Object
Instance Method Details
#filter(params) ⇒ Object
35 36 37 38 |
# File 'app/models/concerns/fae/base_model_concern.rb', line 35 def filter(params) # override this method in your model for_fae_index end |
#filter_all ⇒ Object
30 31 32 33 |
# File 'app/models/concerns/fae/base_model_concern.rb', line 30 def filter_all # override this method in your model for_fae_index end |
#for_fae_index ⇒ Object
13 14 15 |
# File 'app/models/concerns/fae/base_model_concern.rb', line 13 def for_fae_index order(order_method) end |
#order_method ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/models/concerns/fae/base_model_concern.rb', line 17 def order_method klass = name.constantize if klass.column_names.include? 'position' return :position elsif klass.column_names.include? 'name' return :name elsif klass.column_names.include? 'title' return :title else raise "No order_method found, please define for_fae_index as a #{name} class method to set a custom scope." end end |
#to_csv ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'app/models/concerns/fae/base_model_concern.rb', line 40 def to_csv CSV.generate do |csv| csv << column_names all.each do |item| csv << item.attributes.values_at(*column_names) end end end |