Class: MakeTaggable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/make_taggable.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/make_taggable.rb', line 73

def initialize
  @delimiter = ","
  @force_lowercase = false
  @force_parameterize = false
  @strict_case_match = false
  @remove_unused_tags = false
  @tags_counter = true
  @default_parser = DefaultParser
  @force_binary_collation = false
  @tags_table = :tags
  @taggings_table = :taggings
end

Instance Attribute Details

#default_parserObject

Returns the value of attribute default_parser.



67
68
69
# File 'lib/make_taggable.rb', line 67

def default_parser
  @default_parser
end

#delimiterObject

Returns the value of attribute delimiter.



71
72
73
# File 'lib/make_taggable.rb', line 71

def delimiter
  @delimiter
end

#force_lowercaseObject

Returns the value of attribute force_lowercase.



67
68
69
# File 'lib/make_taggable.rb', line 67

def force_lowercase
  @force_lowercase
end

#force_parameterizeObject

Returns the value of attribute force_parameterize.



67
68
69
# File 'lib/make_taggable.rb', line 67

def force_parameterize
  @force_parameterize
end

#remove_unused_tagsObject

Returns the value of attribute remove_unused_tags.



67
68
69
# File 'lib/make_taggable.rb', line 67

def remove_unused_tags
  @remove_unused_tags
end

#strict_case_matchObject

Returns the value of attribute strict_case_match.



71
72
73
# File 'lib/make_taggable.rb', line 71

def strict_case_match
  @strict_case_match
end

#taggings_tableObject

Returns the value of attribute taggings_table.



67
68
69
# File 'lib/make_taggable.rb', line 67

def taggings_table
  @taggings_table
end

#tags_counterObject

Returns the value of attribute tags_counter.



67
68
69
# File 'lib/make_taggable.rb', line 67

def tags_counter
  @tags_counter
end

#tags_tableObject

Returns the value of attribute tags_table.



67
68
69
# File 'lib/make_taggable.rb', line 67

def tags_table
  @tags_table
end

Class Method Details

.apply_binary_collation(bincoll) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/make_taggable.rb', line 112

def self.apply_binary_collation(bincoll)
  if Utils.using_mysql?
    coll = "utf8mb4_general_ci"
    coll = "utf8mb4_bin" if bincoll
    begin
      ActiveRecord::Migration.execute("ALTER TABLE #{Tag.table_name} MODIFY name varchar(255) CHARACTER SET utf8mb4 COLLATE #{coll};")
    rescue => e
      puts "Trapping #{e.class}: collation parameter ignored while migrating for the first time."
    end
  end
end

Instance Method Details

#force_binary_collation=(force_bin) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/make_taggable.rb', line 99

def force_binary_collation=(force_bin)
  if Utils.using_mysql?
    if force_bin
      Configuration.apply_binary_collation(true)
      @force_binary_collation = true
      @strict_case_match = true
    else
      Configuration.apply_binary_collation(false)
      @force_binary_collation = false
    end
  end
end