Exception: Trax::Core::Errors::Base
- Defined in:
- lib/trax/core/errors.rb
Direct Known Subclasses
ConfigurationError, DuplicateEnumValue, InvalidEnumValue, MissingRequiredDependency, MixinNotRegistered
Instance Attribute Summary collapse
-
#arguments_instance ⇒ Object
readonly
Returns the value of attribute arguments_instance.
Class Method Summary collapse
- .argument(method_name, *args) ⇒ Object
-
.error_arguments_klass ⇒ Object
if no properties have been defined using argument method, wrap in Mash.
-
.inherited(subklass) ⇒ Object
on inherit of Trax::Core::Errors::Base, inherit from arguments class above to provide simple dsl options / typecasting and stuff to our errors.
- .message(&block) ⇒ Object
- .permitted_arguments ⇒ Object
- .permitted_arguments_klass ⇒ Object
Instance Method Summary collapse
-
#initialize(**_attributes) ⇒ Base
constructor
A new instance of Base.
- #message ⇒ Object
Constructor Details
#initialize(**_attributes) ⇒ Base
Returns a new instance of Base.
75 76 77 78 79 |
# File 'lib/trax/core/errors.rb', line 75 def initialize(**_attributes) @arguments_instance = self.class.permitted_arguments_klass.new(_attributes) super() end |
Instance Attribute Details
#arguments_instance ⇒ Object (readonly)
Returns the value of attribute arguments_instance.
73 74 75 |
# File 'lib/trax/core/errors.rb', line 73 def arguments_instance @arguments_instance end |
Class Method Details
.argument(method_name, *args) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/trax/core/errors.rb', line 48 def self.argument(method_name, *args) permitted_arguments_klass.property(method_name, *args) define_method(method_name) do arguments_instance.__send__(method_name) end end |
.error_arguments_klass ⇒ Object
if no properties have been defined using argument method, wrap in Mash
69 70 71 |
# File 'lib/trax/core/errors.rb', line 69 def self.error_arguments_klass @error_arguments_klass ||= (permitted_arguments_klass.properties.length) ? permitted_arguments_klass : ::Hashie::Mash end |
.inherited(subklass) ⇒ Object
on inherit of Trax::Core::Errors::Base, inherit from arguments class above to provide simple dsl options / typecasting and stuff to our errors.
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/trax/core/errors.rb', line 36 def self.inherited(subklass) subklass.class_eval do arguments_class_name = "#{subklass.name.demodulize}Arguments" arguments_klass = const_set(arguments_class_name, ::Class.new(::Trax::Core::Errors::Arguments)) unless const_defined?(arguments_class_name) @_permitted_arguments_klass = arguments_klass @_permitted_arguments = arguments_klass.new attr_reader :_permitted_arguments attr_reader :_permitted_arguments_klass end end |
.message(&block) ⇒ Object
64 65 66 |
# File 'lib/trax/core/errors.rb', line 64 def self.(&block) self. = block end |
.permitted_arguments ⇒ Object
60 61 62 |
# File 'lib/trax/core/errors.rb', line 60 def self.permitted_arguments @_permitted_arguments end |
.permitted_arguments_klass ⇒ Object
56 57 58 |
# File 'lib/trax/core/errors.rb', line 56 def self.permitted_arguments_klass @_permitted_arguments_klass end |
Instance Method Details
#message ⇒ Object
81 82 83 |
# File 'lib/trax/core/errors.rb', line 81 def self.instance_eval(&self.class.) end |