Module: MakeTaggable
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/make_taggable.rb,
lib/make_taggable/tag.rb,
lib/make_taggable/utils.rb,
lib/make_taggable/engine.rb,
lib/make_taggable/tagger.rb,
lib/make_taggable/tagging.rb,
lib/make_taggable/version.rb,
lib/make_taggable/tag_list.rb,
lib/make_taggable/taggable.rb,
lib/make_taggable/tags_helper.rb,
lib/make_taggable/default_parser.rb,
lib/make_taggable/generic_parser.rb
Overview
Tagging for Active Record models, across any number of named contexts.
Make a model taggable with Taggable#make_taggable, and configure the library through MakeTaggable.setup. Every setting on Configuration can also be read and written directly here.
Defined Under Namespace
Modules: Taggable, Tagger, TagsHelper, Utils Classes: Configuration, DefaultParser, DuplicateTagError, Engine, GenericParser, Tag, TagList, Tagging
Constant Summary collapse
- VERSION =
The released version of the gem.
"1.7.1"
Class Method Summary collapse
-
.glue ⇒ String
The string used to join tags back together for display, derived from the configured delimiter.
-
.method_missing(method_name, *args, &block) ⇒ Object
Forwards unknown calls to the configuration, so every setting can be read and written directly on
MakeTaggableas well as inside a MakeTaggable.setup block. -
.respond_to_missing?(method_name, include_private = false) ⇒ TrueClass, FalseClass
Reports the configuration's settings as available on
MakeTaggableitself. -
.setup {|configuration| ... } ⇒ MakeTaggable::Configuration, NilClass
Yields the configuration so settings can be assigned in one block.
-
.tag_model ⇒ Class
The class tags are read, written and returned as.
Class Method Details
.glue ⇒ String
The string used to join tags back together for display, derived from the configured delimiter.
A trailing space is added when the delimiter does not already end in one, so a comma delimiter
renders as "one, two" rather than "one,two". When several delimiters are configured the
first is used.
124 125 126 127 128 |
# File 'lib/make_taggable.rb', line 124 def self.glue setting = @configuration.delimiter delimiter = setting.is_a?(Array) ? setting[0] : setting delimiter.end_with?(" ") ? delimiter : "#{delimiter} " end |
.method_missing(method_name, *args, &block) ⇒ Object
Forwards unknown calls to the configuration, so every setting can be read and written directly
on MakeTaggable as well as inside a setup block.
93 94 95 96 97 98 99 |
# File 'lib/make_taggable.rb', line 93 def self.method_missing(method_name, *args, &block) if @configuration.respond_to?(method_name) @configuration.send(method_name, *args, &block) else super end end |
.respond_to_missing?(method_name, include_private = false) ⇒ TrueClass, FalseClass
Reports the configuration's settings as available on MakeTaggable itself.
108 109 110 |
# File 'lib/make_taggable.rb', line 108 def self.respond_to_missing?(method_name, include_private = false) @configuration.respond_to?(method_name, include_private) || super end |
.setup {|configuration| ... } ⇒ MakeTaggable::Configuration, NilClass
Yields the configuration so settings can be assigned in one block.
Called without a block it only ensures the configuration exists, which is how the library initialises itself on load.
75 76 77 78 |
# File 'lib/make_taggable.rb', line 75 def self.setup @configuration ||= Configuration.new yield @configuration if block_given? end |
.tag_model ⇒ Class
The class tags are read, written and returned as.
Resolved on each call rather than memoised, so a reloaded class in development is picked up.
137 138 139 |
# File 'lib/make_taggable.rb', line 137 def self.tag_model tag_class.constantize end |