Module: ActsAsTaggableOn::Utils
- Included in:
- Tag
- Defined in:
- lib/acts_as_taggable_on/utils.rb
Instance Method Summary collapse
- #connection ⇒ Object
- #sha_prefix(string) ⇒ Object
- #using_case_insensitive_collation? ⇒ Boolean
- #using_mysql? ⇒ Boolean
- #using_postgresql? ⇒ Boolean
- #using_sqlite? ⇒ Boolean
Instance Method Details
#connection ⇒ Object
4 5 6 |
# File 'lib/acts_as_taggable_on/utils.rb', line 4 def connection ::ActiveRecord::Base.connection end |
#sha_prefix(string) ⇒ Object
25 26 27 |
# File 'lib/acts_as_taggable_on/utils.rb', line 25 def sha_prefix(string) Digest::SHA1.hexdigest("#{string}#{rand}")[0..6] end |
#using_case_insensitive_collation? ⇒ Boolean
21 22 23 |
# File 'lib/acts_as_taggable_on/utils.rb', line 21 def using_case_insensitive_collation? using_mysql? && ::ActiveRecord::Base.connection.collation =~ /_ci\Z/ end |
#using_mysql? ⇒ Boolean
16 17 18 19 |
# File 'lib/acts_as_taggable_on/utils.rb', line 16 def using_mysql? #We should probably use regex for mysql to support prehistoric adapters connection && connection.adapter_name == 'Mysql2' end |
#using_postgresql? ⇒ Boolean
8 9 10 |
# File 'lib/acts_as_taggable_on/utils.rb', line 8 def using_postgresql? connection && connection.adapter_name == 'PostgreSQL' end |
#using_sqlite? ⇒ Boolean
12 13 14 |
# File 'lib/acts_as_taggable_on/utils.rb', line 12 def using_sqlite? connection && connection.adapter_name == 'SQLite' end |