Module: Cylons::ActiveRecordExtensions::ClassMethods
- Defined in:
- lib/cylons/active_record_extensions.rb
Instance Method Summary collapse
- #reload_remotes! ⇒ Object
- #remote_belongs_to(*args) ⇒ Object
-
#remote_has_many(*args) ⇒ Object
store remote has many assoc globally, then define it locally.
- #remote_schema ⇒ Object
- #search(params = {}) ⇒ Object
Instance Method Details
#reload_remotes! ⇒ Object
11 12 13 |
# File 'lib/cylons/active_record_extensions.rb', line 11 def reload_remotes! ::Cylons::RemoteDiscovery.load_remotes unless ::Cylons.silence? end |
#remote_belongs_to(*args) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cylons/active_record_extensions.rb', line 19 def remote_belongs_to(*args) = args. args.each do |arg| [:foreign_key] = "#{arg}_id" association_hash = {:name => arg, :association_type => :belongs_to, :options => } self.remote_associations << association_hash build_remote_belongs_to_association(association_hash) end end |
#remote_has_many(*args) ⇒ Object
store remote has many assoc globally, then define it locally.
31 32 33 34 35 36 37 38 39 |
# File 'lib/cylons/active_record_extensions.rb', line 31 def remote_has_many(*args) = args. args.each do |arg| association_hash = {:name => arg, :association_type => :has_many, :options => } self.remote_associations << association_hash build_remote_has_many_association(association_hash) end end |
#remote_schema ⇒ Object
15 16 17 |
# File 'lib/cylons/active_record_extensions.rb', line 15 def remote_schema ::Cylons::RemoteRegistry.get_remote_schema(self.name) unless ::Cylons.silence? end |
#search(params = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/cylons/active_record_extensions.rb', line 41 def search(params = {}) = params.extract!(*SEARCH_OPTION_KEYS) .delete_if {|k,v| v.nil? } query_scope = params.inject(all) do |query, hash_pair| query.__send__("by_#{hash_pair[0]}", hash_pair[1]).all end.all end |