Class: ZeroRailsAdapter::Configuration
- Inherits:
-
Object
- Object
- ZeroRailsAdapter::Configuration
- Defined in:
- lib/zero_rails_adapter/configuration.rb
Instance Attribute Summary collapse
-
#authenticator ⇒ Object
Returns the value of attribute authenticator.
-
#authorizer ⇒ Object
Returns the value of attribute authorizer.
-
#crud_authorizer ⇒ Object
Returns the value of attribute crud_authorizer.
-
#crud_model_provider ⇒ Object
Returns the value of attribute crud_model_provider.
-
#generated_attributes ⇒ Object
Returns the value of attribute generated_attributes.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#model_resolver ⇒ Object
Returns the value of attribute model_resolver.
-
#published_schema ⇒ Object
Returns the value of attribute published_schema.
-
#relationship_provider ⇒ Object
Returns the value of attribute relationship_provider.
-
#request_verifier ⇒ Object
Returns the value of attribute request_verifier.
-
#storage_provider ⇒ Object
Returns the value of attribute storage_provider.
-
#transaction_class ⇒ Object
Returns the value of attribute transaction_class.
-
#writable_attributes ⇒ Object
Returns the value of attribute writable_attributes.
-
#zero_key ⇒ Object
Returns the value of attribute zero_key.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/zero_rails_adapter/configuration.rb', line 11 def initialize @authenticator = lambda do |_request| raise UnauthorizedError, "Authentication is not configured" end @request_verifier = ->(_request) { false } @authorizer = ->(_context, _mutation) { false } @crud_authorizer = ->(_context, _action, _target, _attributes) { false } @logger = defined?(Rails) ? Rails.logger : nil @transaction_class = ActiveRecord::Base @published_schema = -> { {} } @crud_model_provider = -> { [] } @zero_key = ->(model) { model.primary_key } @relationship_provider = -> { [] } @model_resolver = lambda do |resource| allowed_models = Array(crud_model_provider.call).select do |model| active_record_model?(model) end candidate = resource.to_s.classify.safe_constantize candidate = nil unless allowed_models.include?(candidate) candidate ||= allowed_models.find { |model| model.table_name == resource.to_s } end @writable_attributes = ->(model, _action, _context) { default_writable_attributes(model) } @generated_attributes = ->(model, _action) { default_writable_attributes(model) } @storage_provider = lambda do |request| Storage::ZeroSchema.new(request:, transaction_class:) end end |
Instance Attribute Details
#authenticator ⇒ Object
Returns the value of attribute authenticator.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def authenticator @authenticator end |
#authorizer ⇒ Object
Returns the value of attribute authorizer.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def @authorizer end |
#crud_authorizer ⇒ Object
Returns the value of attribute crud_authorizer.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def @crud_authorizer end |
#crud_model_provider ⇒ Object
Returns the value of attribute crud_model_provider.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def crud_model_provider @crud_model_provider end |
#generated_attributes ⇒ Object
Returns the value of attribute generated_attributes.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def generated_attributes @generated_attributes end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def logger @logger end |
#model_resolver ⇒ Object
Returns the value of attribute model_resolver.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def model_resolver @model_resolver end |
#published_schema ⇒ Object
Returns the value of attribute published_schema.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def published_schema @published_schema end |
#relationship_provider ⇒ Object
Returns the value of attribute relationship_provider.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def relationship_provider @relationship_provider end |
#request_verifier ⇒ Object
Returns the value of attribute request_verifier.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def request_verifier @request_verifier end |
#storage_provider ⇒ Object
Returns the value of attribute storage_provider.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def storage_provider @storage_provider end |
#transaction_class ⇒ Object
Returns the value of attribute transaction_class.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def transaction_class @transaction_class end |
#writable_attributes ⇒ Object
Returns the value of attribute writable_attributes.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def writable_attributes @writable_attributes end |
#zero_key ⇒ Object
Returns the value of attribute zero_key.
5 6 7 |
# File 'lib/zero_rails_adapter/configuration.rb', line 5 def zero_key @zero_key end |