Class: Editus::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/editus/proxy.rb

Direct Known Subclasses

RecordProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Proxy

Returns a new instance of Proxy.



5
6
7
# File 'lib/editus/proxy.rb', line 5

def initialize klass
  @klass = klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)



37
38
39
# File 'lib/editus/proxy.rb', line 37

def method_missing method, *args, &block
  klass.try(method, *args, &block)
end

Instance Attribute Details

#klassObject (readonly)

Returns the value of attribute klass.



3
4
5
# File 'lib/editus/proxy.rb', line 3

def klass
  @klass
end

Instance Method Details

#column_namesObject



9
10
11
# File 'lib/editus/proxy.rb', line 9

def column_names
  proxied_columns
end

#find_by(*args) ⇒ Object



15
16
17
18
19
20
# File 'lib/editus/proxy.rb', line 15

def find_by *args
  record = klass.find_by(*args)
  return record if record.blank?

  RecordProxy.new(record)
end

#try(*args) ⇒ Object



22
23
24
# File 'lib/editus/proxy.rb', line 22

def try *args
  klass.try(*args)
end

#update_columns(attributes) ⇒ Object



13
# File 'lib/editus/proxy.rb', line 13

def update_columns attributes; end