module Rexport::ExportFilterMethods
Public Instance Methods
attributes_for_copy()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 16 def attributes_for_copy attributes.slice("filter_field", "value") end
display_value()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 12 def display_value filter_on_associated_object? ? associated_object_value : value end
Private Instance Methods
associated_object_value()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 22 def associated_object_value return "UNDEFINED ASSOCIATION" unless filter_association begin object = filter_association.klass.find(value) object.respond_to?(:name) ? object.name : object.to_s rescue ActiveRecord::RecordNotFound "ASSOCIATED OBJECT NOT FOUND" end end
belongs_to_associations()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 43 def belongs_to_associations export.get_klass_from_path(filter_path).reflect_on_all_associations(:belongs_to) end
filter_association()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 33 def filter_association @filter_association ||= find_filter_association end
filter_foreign_key()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 51 def filter_foreign_key filter_field.split(".").last end
filter_on_associated_object?()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 55 def filter_on_associated_object? filter_field[/_id$/] end
filter_path()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 47 def filter_path filter_field.split(".")[0..-2] end
find_filter_association()
click to toggle source
# File lib/rexport/export_filter_methods.rb, line 37 def find_filter_association belongs_to_associations.detect do |association| association.foreign_key == filter_foreign_key end end