Class: GL::Context
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- GL::Context
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/gl/command/context.rb
Overview
rubocop:disable Style/OpenStructUse
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
Class Method Summary collapse
Instance Method Summary collapse
- #fail! ⇒ Object
- #failure? ⇒ Boolean
-
#initialize(args) ⇒ Context
constructor
A new instance of Context.
- #inspect ⇒ Object
- #success? ⇒ Boolean (also: #successful?)
Constructor Details
#initialize(args) ⇒ Context
Returns a new instance of Context.
18 19 20 21 |
# File 'lib/gl/command/context.rb', line 18 def initialize(args) super(args) @errors = ActiveModel::Errors.new(self) end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
9 10 11 |
# File 'lib/gl/command/context.rb', line 9 def errors @errors end |
Class Method Details
.factory(context = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/gl/command/context.rb', line 11 def self.factory(context = {}) return context if context.is_a?(Context) raise NotAContextError, 'Arguments are not a Context.' unless context.respond_to?(:each_pair) Context.new(context) end |
Instance Method Details
#fail! ⇒ Object
23 24 25 |
# File 'lib/gl/command/context.rb', line 23 def fail! @failure = true end |
#failure? ⇒ Boolean
27 28 29 |
# File 'lib/gl/command/context.rb', line 27 def failure? @failure || false end |
#inspect ⇒ Object
36 37 38 |
# File 'lib/gl/command/context.rb', line 36 def inspect "<GL::Context success:#{success?} errors:#{@errors.} data:#{to_h}>" end |
#success? ⇒ Boolean Also known as: successful?
31 32 33 |
# File 'lib/gl/command/context.rb', line 31 def success? !failure? end |