Module: Authlogic::Session::ActiveRecordTrickery::ClassMethods

Defined in:
lib/authlogic/session/active_record_trickery.rb

Instance Method Summary collapse

Instance Method Details

#human_attribute_name(attribute_key_name, options = {}) ⇒ Object

How to name the attributes of Authlogic, works JUST LIKE ActiveRecord, but instead it uses the following namespace:

authlogic.attributes.user_session.


18
19
20
21
22
# File 'lib/authlogic/session/active_record_trickery.rb', line 18

def human_attribute_name(attribute_key_name, options = {})
  options[:count] ||= 1
  options[:default] ||= attribute_key_name.to_s.humanize
  I18n.t("attributes.#{name.underscore}.#{attribute_key_name}", options)
end

#human_name(*args) ⇒ Object

How to name the class, works JUST LIKE ActiveRecord, except it uses the following namespace:

authlogic.models.user_session


27
28
29
# File 'lib/authlogic/session/active_record_trickery.rb', line 27

def human_name(*args)
  I18n.t("models.#{name.underscore}", {:count => 1, :default => name.humanize})
end

#i18n_scopeObject



50
51
52
# File 'lib/authlogic/session/active_record_trickery.rb', line 50

def i18n_scope
  I18n.scope
end

#lookup_ancestorsObject



54
55
56
# File 'lib/authlogic/session/active_record_trickery.rb', line 54

def lookup_ancestors
  ancestors.select { |x| x.respond_to?(:model_name) }
end

#model_nameObject

For rails >= 3.0



42
43
44
45
46
47
48
# File 'lib/authlogic/session/active_record_trickery.rb', line 42

def model_name
  if defined?(::ActiveModel)
    ::ActiveModel::Name.new(self)
  else
    ::ActiveSupport::ModelName.new(self.to_s)
  end
end

#self_and_descendants_from_active_recordObject

For rails >= 2.3, mispelling fixed



37
38
39
# File 'lib/authlogic/session/active_record_trickery.rb', line 37

def self_and_descendants_from_active_record
  [self]
end

#self_and_descendents_from_active_recordObject

For rails < 2.3, mispelled



32
33
34
# File 'lib/authlogic/session/active_record_trickery.rb', line 32

def self_and_descendents_from_active_record
  [self]
end