Class: Axn::Core::ContextFacade
- Inherits:
-
Object
- Object
- Axn::Core::ContextFacade
- Defined in:
- lib/axn/core/context/facade.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#declared_fields ⇒ Object
readonly
Returns the value of attribute declared_fields.
Instance Method Summary collapse
- #fail! ⇒ Object
-
#initialize(action:, context:, declared_fields:, implicitly_allowed_fields: nil) ⇒ ContextFacade
constructor
A new instance of ContextFacade.
- #inspect ⇒ Object
Constructor Details
#initialize(action:, context:, declared_fields:, implicitly_allowed_fields: nil) ⇒ ContextFacade
Returns a new instance of ContextFacade.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/axn/core/context/facade.rb', line 8 def initialize(action:, context:, declared_fields:, implicitly_allowed_fields: nil) if self.class.name == "Axn::Core::ContextFacade" # rubocop:disable Style/ClassEqualityComparison raise "Axn::Core::ContextFacade is an abstract class and should not be instantiated directly" end @context = context @action = action @declared_fields = declared_fields (@declared_fields + Array(implicitly_allowed_fields)).each do |field| _define_reader_for(field) end end |
Instance Attribute Details
#declared_fields ⇒ Object (readonly)
Returns the value of attribute declared_fields.
22 23 24 |
# File 'lib/axn/core/context/facade.rb', line 22 def declared_fields @declared_fields end |
Instance Method Details
#fail! ⇒ Object
26 27 28 |
# File 'lib/axn/core/context/facade.rb', line 26 def fail!(...) raise Axn::ContractViolation::MethodNotAllowed, "Call fail! directly rather than on the context" end |
#inspect ⇒ Object
24 |
# File 'lib/axn/core/context/facade.rb', line 24 def inspect = ContextFacadeInspector.new(facade: self, action:, context:).call |