Class: ElasticAdapter::Decoration::Decorator Abstract

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/elastic_adapter/decoration/decorator.rb

Overview

This class is abstract.

Abstract base class for response decorators

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Decorator

Takes an object and stores it in `@original_object` and saves a altered version as the decorated object


16
17
18
19
# File 'lib/elastic_adapter/decoration/decorator.rb', line 16

def initialize(object)
  @original_object = object
  __setobj__(alter_object(object))
end

Instance Attribute Details

#original_objectObject

the original unmodified object


9
10
11
# File 'lib/elastic_adapter/decoration/decorator.rb', line 9

def original_object
  @original_object
end

Instance Method Details

#alter_object(_object) ⇒ Object

Is intended to alter the passed object to change it's interface


32
33
34
# File 'lib/elastic_adapter/decoration/decorator.rb', line 32

def alter_object(_object)
  fail NotImplementedError, "alter_object must be overriden in subclasses"
end

#objectObject

Returns the underlaying altered object


24
25
26
# File 'lib/elastic_adapter/decoration/decorator.rb', line 24

def object
  __getobj__
end