Class: AbideDevUtils::Ppt::YardObjectWrapper

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#objectObject (readonly)

Returns the value of attribute object.



152
153
154
# File 'lib/abide_dev_utils/ppt/strings.rb', line 152

def object
  @object
end

#validatorObject

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

Returns:

  • (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_hashObject 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_sObject



178
179
180
# File 'lib/abide_dev_utils/ppt/strings.rb', line 178

def to_s
  object.to_s
end