Class: Sandals::BindingResolver
- Inherits:
-
Object
- Object
- Sandals::BindingResolver
- Defined in:
- lib/sandals/binding_resolver.rb
Defined Under Namespace
Classes: Resolution
Constant Summary collapse
- UNSET =
Object.new.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(model:, bind:, value:, error:, action:, default:) ⇒ BindingResolver
constructor
A new instance of BindingResolver.
- #resolve ⇒ Object
Constructor Details
#initialize(model:, bind:, value:, error:, action:, default:) ⇒ BindingResolver
Returns a new instance of BindingResolver.
12 13 14 15 16 17 18 19 |
# File 'lib/sandals/binding_resolver.rb', line 12 def initialize(model:, bind:, value:, error:, action:, default:) @model = model @bind = bind @value = value @error = error @action = action @default = default end |
Class Method Details
.resolve(**options) ⇒ Object
8 9 10 |
# File 'lib/sandals/binding_resolver.rb', line 8 def self.resolve(**) new(**).resolve end |
Instance Method Details
#resolve ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sandals/binding_resolver.rb', line 21 def resolve return explicit_resolution unless binding_requested? validate_binding attribute = @bind.to_sym writer = :"#{attribute}=" validate_accessors(attribute, writer) Resolution.new( @model.public_send(attribute), resolved_error(attribute), ->(new_value) { @model.public_send(writer, new_value) } ) end |