Class: Zertico::Accessor

Inherits:
Object
  • Object
show all
Defined in:
lib/zertico/accessor.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Accessor



3
4
5
# File 'lib/zertico/accessor.rb', line 3

def initialize(object)
  instance_variable_set("@#{interface_name}", object)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



15
16
17
18
19
20
# File 'lib/zertico/accessor.rb', line 15

def method_missing(method_name, *args)
  if interface.respond_to?(method_name)
    return interface.send(method_name, *args)
  end
  super
end

Class Method Details

.find(id) ⇒ Object



7
8
9
# File 'lib/zertico/accessor.rb', line 7

def self.find(id)
  new(interface_class.find(id))
end

Instance Method Details

#interfaceObject



11
12
13
# File 'lib/zertico/accessor.rb', line 11

def interface
  instance_variable_get("@#{interface_name}")
end

#respond_to?(method_name, include_private = false) ⇒ Boolean



23
24
25
26
# File 'lib/zertico/accessor.rb', line 23

def respond_to?(method_name, include_private = false)
  return true if self.interface.respond_to?(method_name)
  super
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean



28
29
30
31
# File 'lib/zertico/accessor.rb', line 28

def respond_to_missing?(method_name, include_private = false)
  return true if self.interface.respond_to?(method_name)
  super
end