Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/quarter_system/argumentation/object.rb
Overview
Custom handling or arguments: Allows things like User.with_arguments(1, 2, 3).find(:order => ‘id DESC’)
result: => User.find(1, 2, 3, :order => 'id DESC')
but also checks to see that arguments are valid.
Also, allows us to condense patterns like: record.perform_action! if record.respond_to?(:perform_action!) by doing the following instead record.maybe.perform_action!
Instance Method Summary collapse
- #with_arguments(*arguments) ⇒ Object
- #with_nonnil(*arguments) ⇒ Object
- #with_present(*arguments) ⇒ Object
Instance Method Details
#with_arguments(*arguments) ⇒ Object
10 11 12 13 |
# File 'lib/quarter_system/argumentation/object.rb', line 10 def with_arguments(*arguments) arg_merger = ArgumentMerger.new(self, arguments) block_given? ? yield(arg_merger) : arg_merger end |
#with_nonnil(*arguments) ⇒ Object
16 |
# File 'lib/quarter_system/argumentation/object.rb', line 16 def with_nonnil(*arguments); with_arguments(*arguments.(:nonnil => true)); end |
#with_present(*arguments) ⇒ Object
17 |
# File 'lib/quarter_system/argumentation/object.rb', line 17 def with_present(*arguments); with_arguments(*arguments.(:present => true)); end |