Module: TheForce::ObjectSupport

Defined in:
lib/the_force/memoize.rb,
lib/the_force/object_support.rb

Defined Under Namespace

Modules: InstanceMethods, Memoization Classes: ConditionalReturningMe

Class Method Summary collapse

Class Method Details

.conditional(who, inverted, *args, &b) ⇒ Object

:doc:



18
19
20
21
22
23
24
25
26
# File 'lib/the_force/object_support.rb', line 18

def self.conditional(who, inverted, *args, &b) # :doc:
  if block_given?
    (inverted ^ yield(who)) ? who : nil
  elsif args.length > 0
    (inverted ^ who.send(*args)) ? who : nil
  else
    ConditionalReturningMe.new(who, inverted)
  end
end