Class: Urge::Base
- Inherits:
-
Object
- Object
- Urge::Base
- Defined in:
- lib/urge/persistence/base.rb
Overview
Persistence
Instance Method Summary collapse
-
#method_in_persistence_base ⇒ Object
def state_with_scope(name, *args) state_without_scope(name, *args) unless @clazz.respond_to?(name) if @clazz.ancestors.map {|klass| klass.to_s}.include?(“ActiveRecord::Base”) scope_options = => { “#{@clazz.table_name.#@[email protected]_column” => name.to_s}} scope_method = ActiveRecord::VERSION::MAJOR >= 3 ? :scope : :named_scope @clazz.send(scope_method, name, scope_options) elsif @clazz.ancestors.map {|klass| klass.to_s}.include?(“Mongoid::Document”) scope_options = lambda { @clazz.send(:where, => name.to_s) } @clazz.send(:scope, name, scope_options) end end end alias_method :state_without_scope, :state alias_method :state, :state_with_scope.
Instance Method Details
#method_in_persistence_base ⇒ Object
def state_with_scope(name, *args)
state_without_scope(name, *args)
unless @clazz.respond_to?(name)
if @clazz.ancestors.map {|klass| klass.to_s}.include?("ActiveRecord::Base")
= {:conditions => { "#{@clazz.table_name}.#{@clazz.aasm_column}" => name.to_s}}
scope_method = ActiveRecord::VERSION::MAJOR >= 3 ? :scope : :named_scope
@clazz.send(scope_method, name, )
elsif @clazz.ancestors.map {|klass| klass.to_s}.include?("Mongoid::Document")
= lambda { @clazz.send(:where, {@clazz.aasm_column.to_sym => name.to_s}) }
@clazz.send(:scope, name, )
end
end
end alias_method :state_without_scope, :state alias_method :state, :state_with_scope
69 70 71 |
# File 'lib/urge/persistence/base.rb', line 69 def method_in_persistence_base "This is method_in_persistence_base" end |