Module: ActivePath::ViewInjection::Conditions::Conditional
- Included in:
- Subscriber
- Defined in:
- lib/active_path/view_injection/conditions/conditional.rb
Instance Method Summary collapse
- #condition_match?(condition) ⇒ Boolean
- #conditions_match?(conditions) ⇒ Boolean
- #hash_match?(condition) ⇒ Boolean
- #proc_match?(condition) ⇒ Boolean
Instance Method Details
#condition_match?(condition) ⇒ Boolean
11 12 13 14 15 16 17 |
# File 'lib/active_path/view_injection/conditions/conditional.rb', line 11 def condition_match?(condition) if condition.is_a?(Hash) hash_match?(condition) elsif condition.is_a?(Proc) proc_match?(condition) end end |
#conditions_match?(conditions) ⇒ Boolean
5 6 7 8 9 |
# File 'lib/active_path/view_injection/conditions/conditional.rb', line 5 def conditions_match?(conditions) conditions.all? do |condition| condition_match?(condition) end end |
#hash_match?(condition) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/active_path/view_injection/conditions/conditional.rb', line 19 def hash_match?(condition) condition.all? do |k,v| [:locals][k] == v end end |
#proc_match?(condition) ⇒ Boolean
25 26 27 |
# File 'lib/active_path/view_injection/conditions/conditional.rb', line 25 def proc_match?(condition) condition.call([:locals]) end |