Module: Serpentine::ControllerHelper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/serpentine.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #apply_scope_if?(operator) ⇒ Boolean
- #apply_scope_unless?(operator) ⇒ Boolean
- #apply_scopes! ⇒ Object
- #apply_scopes?(options) ⇒ Boolean
- #collection=(collection) ⇒ Object
Instance Method Details
#apply_scope_if?(operator) ⇒ Boolean
35 36 37 |
# File 'lib/serpentine.rb', line 35 def apply_scope_if?(operator) operator && (operator.respond_to?(:call) ? operator.call(params) : send(operator)) end |
#apply_scope_unless?(operator) ⇒ Boolean
39 40 41 |
# File 'lib/serpentine.rb', line 39 def apply_scope_unless?(operator) operator && (operator.respond_to?(:call) ? !operator.call(params) : !send(operator)) end |
#apply_scopes! ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/serpentine.rb', line 21 def apply_scopes! self.class.collection_filters.each do |callback| if apply_scopes?(callback.) self.collection = send callback.name end end end |
#apply_scopes?(options) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/serpentine.rb', line 29 def apply_scopes?() apply_scope_if?([:if]) || apply_scope_unless?([:unless]) || ![:if] && ![:unless] end |
#collection=(collection) ⇒ Object
43 44 45 |
# File 'lib/serpentine.rb', line 43 def collection=(collection) @collection = collection end |