Class: AbideDevUtils::Ppt::YardObjectWrapper
- Inherits:
-
Object
- Object
- AbideDevUtils::Ppt::YardObjectWrapper
- Defined in:
- lib/abide_dev_utils/ppt/strings.rb
Overview
Wrapper class for Yard objects that allows associating things like validators with them
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#validator ⇒ Object
Returns the value of attribute validator.
Instance Method Summary collapse
-
#initialize(object, validator: nil) ⇒ YardObjectWrapper
constructor
A new instance of YardObjectWrapper.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
- #to_hash ⇒ Object (also: #to_h)
- #to_s ⇒ Object
Constructor Details
#initialize(object, validator: nil) ⇒ YardObjectWrapper
Returns a new instance of YardObjectWrapper.
154 155 156 157 |
# File 'lib/abide_dev_utils/ppt/strings.rb', line 154 def initialize(object, validator: nil) @object = object @validator = validator end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
159 160 161 162 163 164 165 166 167 |
# File 'lib/abide_dev_utils/ppt/strings.rb', line 159 def method_missing(method, *args, &block) if object.respond_to?(method) object.send(method, *args, &block) elsif validator.respond_to?(method) validator.send(method, *args, &block) else super end end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
152 153 154 |
# File 'lib/abide_dev_utils/ppt/strings.rb', line 152 def object @object end |
#validator ⇒ Object
Returns the value of attribute validator.
151 152 153 |
# File 'lib/abide_dev_utils/ppt/strings.rb', line 151 def validator @validator end |
Instance Method Details
#respond_to_missing?(method, include_private = false) ⇒ Boolean
169 170 171 |
# File 'lib/abide_dev_utils/ppt/strings.rb', line 169 def respond_to_missing?(method, include_private = false) object.respond_to?(method) || validator.respond_to?(method) || super end |
#to_hash ⇒ Object Also known as: to_h
173 174 175 |
# File 'lib/abide_dev_utils/ppt/strings.rb', line 173 def to_hash object.to_hash end |
#to_s ⇒ Object
178 179 180 |
# File 'lib/abide_dev_utils/ppt/strings.rb', line 178 def to_s object.to_s end |