Class: Zodra::Contract
- Inherits:
-
Object
- Object
- Zodra::Contract
- Defined in:
- lib/zodra/contract.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
- #add_action(action_name) ⇒ Object
- #find(type_name) ⇒ Object
- #find_action(action_name) ⇒ Object
-
#initialize(name:) ⇒ Contract
constructor
A new instance of Contract.
- #resolve_type(type_name) ⇒ Object (also: #find!)
Constructor Details
#initialize(name:) ⇒ Contract
Returns a new instance of Contract.
7 8 9 10 11 |
# File 'lib/zodra/contract.rb', line 7 def initialize(name:) @name = name @actions = {} @types = TypeRegistry.new end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
5 6 7 |
# File 'lib/zodra/contract.rb', line 5 def actions @actions end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/zodra/contract.rb', line 5 def name @name end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
5 6 7 |
# File 'lib/zodra/contract.rb', line 5 def types @types end |
Instance Method Details
#add_action(action_name) ⇒ Object
13 14 15 16 17 |
# File 'lib/zodra/contract.rb', line 13 def add_action(action_name) action = Action.new(name: action_name, contract: self) @actions[action_name.to_sym] = action action end |
#find(type_name) ⇒ Object
29 30 31 |
# File 'lib/zodra/contract.rb', line 29 def find(type_name) types.find(type_name) || TypeRegistry.global.find(type_name) end |
#find_action(action_name) ⇒ Object
19 20 21 |
# File 'lib/zodra/contract.rb', line 19 def find_action(action_name) @actions[action_name.to_sym] end |
#resolve_type(type_name) ⇒ Object Also known as: find!
23 24 25 |
# File 'lib/zodra/contract.rb', line 23 def resolve_type(type_name) types.find(type_name) || TypeRegistry.global.find!(type_name) end |