Sha256: 0ce11a3b542d1f0bc2767631fb6a4ffde21caac5cc421c475b0aab7b94051f28
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true module LightServiceExt class ApplicationContext < LightService::Context OVERRIDABLE_DEFAULT_KEYS = %i[errors params allow_raise_on_failure].freeze class << self def make_with_defaults(input = {}, overrides = {}) allowed_overrides = overrides.slice(*OVERRIDABLE_DEFAULT_KEYS) make({ input: input.symbolize_keys }.merge(default_attrs, allowed_overrides)) end private def default_attrs { errors: {}, params: {}, successful_actions: [], api_responses: [], allow_raise_on_failure: true }.freeze end end def invoked_action self[:invoked_action] end def validation_errors self[:errors] end def allow_raise_on_failure? !!self[:allow_raise_on_failure] end def method_missing(method_name, *arguments, &block) return self[method_name] if key?(method_name) super end def respond_to_missing?(method_name, include_private = false) key?(method_name) || super end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
light-service-ext-0.1.1 | lib/light-service-ext/application_context.rb |
light-service-ext-0.1.0 | lib/light-service-ext/application_context.rb |