Module: Knight::InstanceMethods
- Defined in:
- lib/knight/instance_methods.rb
Overview
Base functionality that added when included to a class
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- DEFAULT_CONTEXT =
:default
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
private
Return the resource.
Class Method Summary collapse
-
.included(base) ⇒ undefined
private
Extend base class to support validation.
Instance Method Summary collapse
-
#initialize(resource) ⇒ undefined
private
Set the resource.
-
#run(context = DEFAULT_CONTEXT) ⇒ Result
Return the validation result.
Instance Attribute Details
#resource ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return the resource
14 15 16 |
# File 'lib/knight/instance_methods.rb', line 14 def resource @resource end |
Class Method Details
.included(base) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Extend base class to support validation
23 24 25 26 |
# File 'lib/knight/instance_methods.rb', line 23 def self.included(base) super base.extend(ClassMethods) end |
Instance Method Details
#initialize(resource) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set the resource
35 36 37 |
# File 'lib/knight/instance_methods.rb', line 35 def initialize(resource) @resource = resource end |
#run(context = DEFAULT_CONTEXT) ⇒ Result
Return the validation result
55 56 57 |
# File 'lib/knight/instance_methods.rb', line 55 def run(context = DEFAULT_CONTEXT) self.class.validator(context).run(resource) end |