Class: ElasticWeb::Relation

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticweb/relation.rb

Direct Known Subclasses

RelationCollection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Relation

Returns a new instance of Relation.



5
6
7
# File 'lib/elasticweb/relation.rb', line 5

def initialize(data)
  @data = OpenStruct.new(data)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *arguments, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/elasticweb/relation.rb', line 9

def method_missing(method_sym, *arguments, &block)
  if @data.respond_to?(method_sym)
    @data.send(method_sym)
  else
    super
  end
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



3
4
5
# File 'lib/elasticweb/relation.rb', line 3

def data
  @data
end