Module: EcoRake::Option::DefaultLookup

Included in:
EcoRake::Option
Defined in:
lib/eco-rake/option/default_lookup.rb

Overview

To prevent dependencies, it should resolve via parent, where parent doesn't get new methods installed on the fly, but where the parent does have the final result (method or const)

Instance Method Summary collapse

Instance Method Details

#default(&block) ⇒ Object

Default may be a lookup



15
16
17
18
19
20
# File 'lib/eco-rake/option/default_lookup.rb', line 15

def default(&block)
  return @default unless default_lookup?
  result = self.class.safe_call(@default, parent, &block)
  result = self.class.safe_call(result, &block) if [Proc, Method].any? {|k| result.is_a?(k)}
  result
end

#type_coercionClass, NilClass

TODO:

link to default resolver, but indirectly

Returns:

  • (Class, NilClass)


24
25
26
27
28
29
30
# File 'lib/eco-rake/option/default_lookup.rb', line 24

def type_coercion
  return @type_coercion if @type_coercion
  return nil            unless default?
  value = default
  return nil if value.nil?
  value.class
end