Class: Apiwork::Adapter::Capability::API::Scope
- Inherits:
-
Object
- Object
- Apiwork::Adapter::Capability::API::Scope
- Defined in:
- lib/apiwork/adapter/capability/api/scope.rb
Overview
Aggregated scope for capability API builders.
Provides access to data collected across all representations in the API. Use this to query API-wide state when building shared types.
Instance Method Summary collapse
-
#configured(capability, key) ⇒ Set
The configured values for a capability.
-
#filter_types ⇒ Set<Symbol>
Returns all filterable types across representations.
-
#filterable? ⇒ Boolean
Returns whether any representation has filterable attributes.
-
#index_actions? ⇒ Boolean
Returns whether any resource has index actions.
-
#initialize(api_class) ⇒ Scope
constructor
A new instance of Scope.
-
#nullable_filter_types ⇒ Set<Symbol>
Returns filterable types that can be null.
-
#sortable? ⇒ Boolean
Returns whether any representation has sortable attributes.
Constructor Details
#initialize(api_class) ⇒ Scope
Returns a new instance of Scope.
13 14 15 16 |
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 13 def initialize(api_class) @representation_registry = api_class.representation_registry @root_resource = api_class.root_resource end |
Instance Method Details
#configured(capability, key) ⇒ Set
The configured values for a capability.
57 58 59 |
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 57 def configured(capability, key) @representation_registry.(capability, key) end |
#filter_types ⇒ Set<Symbol>
Returns all filterable types across representations.
43 44 45 46 47 |
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 43 delegate :filter_types, :filterable?, :nullable_filter_types, :sortable?, to: :@representation_registry |
#filterable? ⇒ Boolean
Returns whether any representation has filterable attributes.
43 44 45 46 47 |
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 43 delegate :filter_types, :filterable?, :nullable_filter_types, :sortable?, to: :@representation_registry |
#index_actions? ⇒ Boolean
Returns whether any resource has index actions.
22 |
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 22 delegate :index_actions?, to: :@root_resource |
#nullable_filter_types ⇒ Set<Symbol>
Returns filterable types that can be null.
43 44 45 46 47 |
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 43 delegate :filter_types, :filterable?, :nullable_filter_types, :sortable?, to: :@representation_registry |
#sortable? ⇒ Boolean
Returns whether any representation has sortable attributes.
43 44 45 46 47 |
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 43 delegate :filter_types, :filterable?, :nullable_filter_types, :sortable?, to: :@representation_registry |