Module: AASM::Persistence::ActiveRecordPersistence::NamedScopeMethods

Defined in:
lib/alexrevin-aasm_numerical/persistence/active_record_persistence.rb

Instance Method Summary collapse

Instance Method Details

#aasm_state_with_scope(name, options = {}) ⇒ Object



244
245
246
247
248
249
250
251
252
253
# File 'lib/alexrevin-aasm_numerical/persistence/active_record_persistence.rb', line 244

def aasm_state_with_scope name, options = {}
  aasm_state_without_scope name, options
  
  unless self.respond_to?(name)
    scope_options = {:conditions => { "#{table_name}.#{self.aasm_column}" => name.to_s}}
    scope_method = ActiveRecord::VERSION::MAJOR >= 3 ? :scope : :named_scope
    self.send(scope_method, name, scope_options)
  end
  
end