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
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 = Validator::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
13 14 15 |
# File 'lib/knight/instance_methods.rb', line 13 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
22 23 24 25 |
# File 'lib/knight/instance_methods.rb', line 22 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
34 35 36 |
# File 'lib/knight/instance_methods.rb', line 34 def initialize(resource) @resource = resource end |
#run(context = Validator::DEFAULT_CONTEXT) ⇒ Result
Return the validation result
53 54 55 |
# File 'lib/knight/instance_methods.rb', line 53 def run(context = Validator::DEFAULT_CONTEXT) self.class.validator.run(resource, context) end |