Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using mattr_accessor, fixes up to the postgres :limit issue. #404

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
appraise "rails-3" do
gem "rails", "3.2.13"
gem "rails", "3.2.16"
end

appraise "rails-4" do
gem "rails", "4.0.0.beta1"
gem "rails", "4.0.2"
end
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ CSS:

## Configuration

Configuration can be done using the initializer provided by running `rails generate acts_as_taggable_on:install`. The below options can be set in the setup block provided or directly on `ActsAsTaggableOn`. Options are as follows:

If you would like to remove unused tag objects after removing taggings, add:

```ruby
Expand Down
23 changes: 8 additions & 15 deletions lib/acts-as-taggable-on.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,17 @@
require "digest/sha1"

module ActsAsTaggableOn
mattr_accessor :delimiter
@@delimiter = ','
include ActiveSupport::Configurable

mattr_accessor :force_lowercase
@@force_lowercase = false

mattr_accessor :force_parameterize
@@force_parameterize = false

mattr_accessor :strict_case_match
@@strict_case_match = false

mattr_accessor :remove_unused_tags
self.remove_unused_tags = false
config_accessor(:delimiter) { ',' }
config_accessor(:force_lowercase) { false }
config_accessor(:force_parameterize) { false }
config_accessor(:strict_case_match) { false }
config_accessor(:remove_unused_tags) { false }

def self.glue
delimiter = @@delimiter.kind_of?(Array) ? @@delimiter[0] : @@delimiter
delimiter.ends_with?(" ") ? delimiter : "#{delimiter} "
glue = delimiter.kind_of?(Array) ? delimiter[0] : delimiter
glue.ends_with?(" ") ? glue : "#{glue} "
end

def self.setup
Expand Down
14 changes: 14 additions & 0 deletions lib/generators/acts_as_taggable_on/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module ActsAsTaggableOn
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path("../../templates", __FILE__)
desc "Creates the ActsAsTaggableOn initializer for your application"

def copy_initializer
template "acts_as_taggable_on_initializer.rb", "config/initializers/acts_as_taggable_on.rb"

puts 'Install completed. Configure ActsAsTaggableOn in config/initializers/acts_as_taggable_on.rb'
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ActsAsTaggableOn.setup do |config|
# The delimiter can be set as a single string or an array or strings.
# If an array is set, any of the strings in the array can be used to separate
# tags, but the first item in the array will be used as the default when
# displaying tag lists. The default is ','.
# config.delimiter = [',', ';']

# Setting +force_lowercase+ to true will downcase tag names when saved.
# Default is false.
# config.force_lowercase = true

# Set to true if you would like to remove unused tag objects after removing
# taggings. Default is false.
# config.remove_unused_tags = true

# Set to true to parameterize tags before saving them. Default is false.
# config.force_parameterize = true

# Set to true if tags should be case-sensitive, i.e. they will not use LIKE
# queries for creation. Default is false.
# config.strict_case_match = true
end