module MopedMapping::SessionContextExt
Constants
- COLLECTION_COMMAND_NAMES
- COMMAND_ARGS_ARRAY
- FULL_NAME_COMMAND_NAMES
Public Class Methods
included(klass)
click to toggle source
# File lib/moped_mapping/session_context_ext.rb, line 5 def self.included(klass) klass.module_eval do %w[query insert update remove command].each do |m| alias_method :"#{m}_without_mapping", m.to_sym alias_method m.to_sym, :"#{m}_with_mapping" end end end
Public Instance Methods
command_with_mapping(database, command, &block)
click to toggle source
# File lib/moped_mapping/session_context_ext.rb, line 75 def command_with_mapping(database, command, &block) done = false COLLECTION_COMMAND_NAMES.each do |name| next unless command.key?(name) command[name] = MopedMapping.mapped_name(database, command[name]) done = true break end unless done COMMAND_ARGS_ARRAY.each do |args| next unless command.key?(args.first) args.each do |arg| command[arg] = MopedMapping.mapped_name(database, command[arg]) end done = true break end end unless done FULL_NAME_COMMAND_NAMES.each do |name| next unless command.key?(name) command[name] = MopedMapping.mapped_full_name(database, command[name]) end end return command_without_mapping(database, command, &block) end
insert_with_mapping(database, collection, documents, options = {}, &block)
click to toggle source
# File lib/moped_mapping/session_context_ext.rb, line 19 def insert_with_mapping(database, collection, documents, options = {}, &block) collection = MopedMapping.mapped_name(database, collection) return insert_without_mapping(database, collection, documents, options, &block) end
query_with_mapping(database, collection, selector, options = {}, &block)
click to toggle source
# File lib/moped_mapping/session_context_ext.rb, line 14 def query_with_mapping(database, collection, selector, options = {}, &block) collection = MopedMapping.mapped_name(database, collection) return query_without_mapping(database, collection, selector, options, &block) end
remove_with_mapping(database, collection, selector, options = {}, &block)
click to toggle source
# File lib/moped_mapping/session_context_ext.rb, line 29 def remove_with_mapping(database, collection, selector, options = {}, &block) collection = MopedMapping.mapped_name(database, collection) return remove_without_mapping(database, collection, selector, options, &block) end
update_with_mapping(database, collection, selector, change, options = {}, &block)
click to toggle source
# File lib/moped_mapping/session_context_ext.rb, line 24 def update_with_mapping(database, collection, selector, change, options = {}, &block) collection = MopedMapping.mapped_name(database, collection) return update_without_mapping(database, collection, selector, change, options, &block) end