Module: Disposable::Twin::Default

Defined in:
lib/disposable/twin/default.rb

Overview

TODO: allow default: -> for hashes, etc.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(includer) ⇒ Object



24
25
26
# File 'lib/disposable/twin/default.rb', line 24

def self.included(includer)
  includer.extend ClassMethods
end

Instance Method Details

#default_for(dfn, options) ⇒ Object



9
10
11
12
13
14
# File 'lib/disposable/twin/default.rb', line 9

def default_for(dfn, options)
  # TODO: introduce Null object in Declarative::Definition#[].
  # dfn[:default].(self) # dfn#[] should return a Null object here if empty.
  return unless dfn[:default]
  dfn[:default].(self)
end

#setup_value_for(dfn, options) ⇒ Object



3
4
5
6
7
# File 'lib/disposable/twin/default.rb', line 3

def setup_value_for(dfn, options)
  value = super
  return value unless value.nil?
  default_for(dfn, options)
end