Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/creative_rails_utilities/object.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.chain_if(switch, operator, *args) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/creative_rails_utilities/object.rb', line 3 def self.chain_if(switch, operator, *args) raise_chain_if_argument_error unless operator.class == Proc || operator.respond_to?(:to_sym) return self unless switch if operator.class == Proc operator.call(self) elsif operator.respond_to?(:to_sym) return self.public_send(operator.to_sym, *args) else raise_chain_if_argument_error end end |
Instance Method Details
#chain_if(switch, operator, *args) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/creative_rails_utilities/object.rb', line 17 def chain_if(switch, operator, *args) raise_chain_if_argument_error unless operator.class == Proc || operator.respond_to?(:to_sym) return self unless switch if operator.class == Proc operator.call(self) elsif operator.respond_to?(:to_sym) return self.public_send(operator.to_sym, *args) else raise_chain_if_argument_error end end |