Class: Apiwork::Adapter::Capability::API::Scope

Inherits:
Object
  • Object
show all
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

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.

Parameters:

  • capability (Symbol)

    The capability name.

  • key (Symbol)

    The configuration key.

Returns:

  • (Set)


57
58
59
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 57

def configured(capability, key)
  @representation_registry.options_for(capability, key)
end

#filter_typesSet<Symbol>

Returns all filterable types across representations.

Returns:

  • (Set<Symbol>)


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.

Returns:

  • (Boolean)


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.

Returns:

  • (Boolean)


22
# File 'lib/apiwork/adapter/capability/api/scope.rb', line 22

delegate :index_actions?, to: :@root_resource

#nullable_filter_typesSet<Symbol>

Returns filterable types that can be null.

Returns:

  • (Set<Symbol>)


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.

Returns:

  • (Boolean)


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