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
26 27 28 |
# File 'lib/disposable/twin/default.rb', line 26 def self.included(includer) includer.extend ClassMethods end |
Instance Method Details
#default_for(dfn, options) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/disposable/twin/default.rb', line 11 def default_for(dfn, ) # 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
5 6 7 8 9 |
# File 'lib/disposable/twin/default.rb', line 5 def setup_value_for(dfn, ) value = super return value unless value.nil? default_for(dfn, ) end |