Class: Urge::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/urge/persistence/base.rb

Overview

Persistence

Instance Method Summary collapse

Instance Method Details

#method_in_persistence_baseObject

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 = {:conditions => { "#{@clazz.table_name}.#{@clazz.aasm_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, {@clazz.aasm_column.to_sym => name.to_s}) }
    @clazz.send(:scope, name, scope_options)
  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