Module: BelongsToProxies::ClassMethods

Defined in:
app/models/concerns/belongs_to_proxies.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to_proxy(name, options) ⇒ Object


13
14
15
# File 'app/models/concerns/belongs_to_proxies.rb', line 13

def belongs_to_proxy(name, options)
  register_smart_proxy(name, options)
end

#register_smart_proxies_from_pluginsObject


23
24
25
26
27
# File 'app/models/concerns/belongs_to_proxies.rb', line 23

def register_smart_proxies_from_plugins
  my_smart_proxies_from_plugins.each do |name, options|
    register_smart_proxy(name, options)
  end
end

#register_smart_proxy(name, options) ⇒ Object


17
18
19
20
21
# File 'app/models/concerns/belongs_to_proxies.rb', line 17

def register_smart_proxy(name, options)
  self.registered_smart_proxies = registered_smart_proxies.merge(name => options)
  belongs_to name, :class_name => 'SmartProxy'
  validates name, :proxy_features => { :feature => options[:feature], :required => options[:required] }
end