Class: Interactify::Contracts::Promising
- Inherits:
-
Object
- Object
- Interactify::Contracts::Promising
- Defined in:
- lib/interactify/contracts/promising.rb
Instance Attribute Summary collapse
-
#interactor ⇒ Object
readonly
Returns the value of attribute interactor.
-
#promising ⇒ Object
readonly
Returns the value of attribute promising.
Class Method Summary collapse
Instance Method Summary collapse
- #format_keys(keys) ⇒ Object
-
#initialize(interactor, *promising) ⇒ Promising
constructor
A new instance of Promising.
- #promised_keys ⇒ Object
- #validate ⇒ Object
Constructor Details
#initialize(interactor, *promising) ⇒ Promising
Returns a new instance of Promising.
16 17 18 19 |
# File 'lib/interactify/contracts/promising.rb', line 16 def initialize(interactor, *promising) @interactor = interactor @promising = format_keys promising end |
Instance Attribute Details
#interactor ⇒ Object (readonly)
Returns the value of attribute interactor.
8 9 10 |
# File 'lib/interactify/contracts/promising.rb', line 8 def interactor @interactor end |
#promising ⇒ Object (readonly)
Returns the value of attribute promising.
8 9 10 |
# File 'lib/interactify/contracts/promising.rb', line 8 def promising @promising end |
Class Method Details
.validate(interactor, *promising) ⇒ Object
10 11 12 13 14 |
# File 'lib/interactify/contracts/promising.rb', line 10 def self.validate(interactor, *promising) new(interactor, *promising).validate interactor end |
Instance Method Details
#format_keys(keys) ⇒ Object
31 32 33 |
# File 'lib/interactify/contracts/promising.rb', line 31 def format_keys(keys) Array(keys).compact.map(&:to_sym).sort end |
#promised_keys ⇒ Object
27 28 29 |
# File 'lib/interactify/contracts/promising.rb', line 27 def promised_keys format_keys interactor.promised_keys end |
#validate ⇒ Object
21 22 23 24 25 |
# File 'lib/interactify/contracts/promising.rb', line 21 def validate return if promising == promised_keys raise MismatchingPromiseError.new(interactor, promising, promised_keys) end |