Module: EffectiveReportsHelper
- Defined in:
- app/helpers/effective_reports_helper.rb
Instance Method Summary collapse
- #reportable_attributes_collection(attributes) ⇒ Object
- #reportable_boolean_collection ⇒ Object
- #reportable_operations_collection(type) ⇒ Object
- #reportable_scopes_collection(scopes) ⇒ Object
Instance Method Details
#reportable_attributes_collection(attributes) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/helpers/effective_reports_helper.rb', line 7 def reportable_attributes_collection(attributes) macros = [:belongs_to, :belongs_to_polymorphic, :has_many, :has_one] { 'Attributes' => attributes.select { |_, type| macros.exclude?(type) }.map { |att, _| [att, att] }.sort, 'Associations' => attributes.select { |_, type| macros.include?(type) }.map { |att, _| [att, att] }.sort, } end |
#reportable_boolean_collection ⇒ Object
3 4 5 |
# File 'app/helpers/effective_reports_helper.rb', line 3 def reportable_boolean_collection [['Yes', true], ['No', false]] end |
#reportable_operations_collection(type) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/helpers/effective_reports_helper.rb', line 23 def reportable_operations_collection(type) case type when :boolean [ ['Equals', :eq], ['Does Not Equal', :not_eq] ] when :string [ ['Equals =', :eq], ['Does Not Equal !=', :not_eq], ['Includes', :matches], ['Does Not Include', :does_not_match], ['Starts with', :starts_with], ['Ends with', :ends_with] ] when :integer, :price, :date, :decimal [ ['Equals =', :eq], ['Does Not Equal !=', :not_eq], ['Greater than >', :gt], ['Greater than or equal to >=', :gteq], ['Less than <', :lt], ['Less than or equal to <=', :lteq], ] when :belongs_to, :belongs_to_polymorphic, :has_many, :has_one [ ['ID(s) Equals =', :eq], ['Matches', :matches], ['Does Not Match', :does_not_match], ['SQL', :sql], ] else raise("unexpected reportable operations collection type: #{type || 'nil'}") end end |
#reportable_scopes_collection(scopes) ⇒ Object
16 17 18 19 20 21 |
# File 'app/helpers/effective_reports_helper.rb', line 16 def reportable_scopes_collection(scopes) { 'Basic' => scopes.select { |_, type| type.blank? }.map { |scope, _| [scope, scope] }.sort, 'Advanced' => scopes.select { |_, type| type.present? }.map { |scope, _| [scope, scope] }.sort } end |