Class: Apiwork::Introspection::Contract
- Inherits:
-
Object
- Object
- Apiwork::Introspection::Contract
- Defined in:
- lib/apiwork/introspection/contract.rb
Overview
Facade for introspected contract data.
Provides access to actions, types, and enums defined on this contract.
Instance Method Summary collapse
-
#actions ⇒ Hash{Symbol => Introspection::Action}
The actions for this contract.
-
#enums ⇒ Hash{Symbol => Enum}
The enums for this contract.
-
#initialize(dump) ⇒ Contract
constructor
A new instance of Contract.
-
#to_h ⇒ Hash
Converts this contract to a hash.
-
#types ⇒ Hash{Symbol => Type}
The types for this contract.
Constructor Details
#initialize(dump) ⇒ Contract
Returns a new instance of Contract.
22 23 24 |
# File 'lib/apiwork/introspection/contract.rb', line 22 def initialize(dump) @dump = dump end |
Instance Method Details
#actions ⇒ Hash{Symbol => Introspection::Action}
The actions for this contract.
30 31 32 |
# File 'lib/apiwork/introspection/contract.rb', line 30 def actions @actions ||= @dump[:actions].transform_values { |dump| Action.new(dump) } end |
#enums ⇒ Hash{Symbol => Enum}
The enums for this contract.
46 47 48 |
# File 'lib/apiwork/introspection/contract.rb', line 46 def enums @enums ||= @dump[:enums].transform_values { |dump| Enum.new(dump) } end |
#to_h ⇒ Hash
Converts this contract to a hash.
54 55 56 57 58 59 60 |
# File 'lib/apiwork/introspection/contract.rb', line 54 def to_h { actions: actions.transform_values(&:to_h), enums: enums.transform_values(&:to_h), types: types.transform_values(&:to_h), } end |