Class: NoFlyList::TaggableRecord::TagSetup
- Inherits:
-
Object
- Object
- NoFlyList::TaggableRecord::TagSetup
- Defined in:
- lib/no_fly_list/taggable_record/tag_setup.rb
Overview
Handles setup and configuration of tagging for a model
Instance Attribute Summary collapse
-
#adapter ⇒ Symbol
readonly
Database adapter type (:postgresql, :mysql, :sqlite).
-
#context ⇒ Symbol
readonly
Tagging context name.
-
#counter_cache ⇒ Boolean
readonly
Whether to use counter cache.
-
#limit ⇒ Integer?
readonly
Maximum number of tags allowed.
-
#polymorphic ⇒ Boolean
readonly
Whether tags are polymorphic.
-
#restrict_to_existing ⇒ Boolean
readonly
Whether to restrict to existing tags.
-
#tag_class_name ⇒ String
readonly
Name of tag class.
-
#taggable_klass ⇒ Class
readonly
Model class being made taggable.
-
#tagging_class_name ⇒ String
readonly
Name of tagging class.
-
#transformer ⇒ Class
readonly
Tag string transformer.
Instance Method Summary collapse
-
#initialize(taggable_klass, context, options = {}) ⇒ TagSetup
constructor
Creates new tag setup configuration.
Constructor Details
#initialize(taggable_klass, context, options = {}) ⇒ TagSetup
Creates new tag setup configuration
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 41 def initialize(taggable_klass, context, = {}) @taggable_klass = taggable_klass @context = context @transformer = .fetch(:transformer, ApplicationTagTransformer) @polymorphic = .fetch(:polymorphic, false) @restrict_to_existing = .fetch(:restrict_to_existing, false) @counter_cache = .fetch(:counter_cache, false) @counter_cache_column = "#{context}_count" @limit = .fetch(:limit, nil) @tag_class_name = determine_tag_class_name(taggable_klass, ) @tagging_class_name = determine_tagging_class_name(taggable_klass, ) @adapter = determine_adapter end |
Instance Attribute Details
#adapter ⇒ Symbol (readonly)
Returns Database adapter type (:postgresql, :mysql, :sqlite).
35 36 37 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 35 def adapter @adapter end |
#context ⇒ Symbol (readonly)
Returns Tagging context name.
11 12 13 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 11 def context @context end |
#counter_cache ⇒ Boolean (readonly)
Returns Whether to use counter cache.
26 27 28 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 26 def counter_cache @counter_cache end |
#limit ⇒ Integer? (readonly)
Returns Maximum number of tags allowed.
23 24 25 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 23 def limit @limit end |
#polymorphic ⇒ Boolean (readonly)
Returns Whether tags are polymorphic.
17 18 19 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 17 def polymorphic @polymorphic end |
#restrict_to_existing ⇒ Boolean (readonly)
Returns Whether to restrict to existing tags.
20 21 22 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 20 def restrict_to_existing @restrict_to_existing end |
#tag_class_name ⇒ String (readonly)
Returns Name of tag class.
29 30 31 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 29 def tag_class_name @tag_class_name end |
#taggable_klass ⇒ Class (readonly)
Returns Model class being made taggable.
8 9 10 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 8 def taggable_klass @taggable_klass end |
#tagging_class_name ⇒ String (readonly)
Returns Name of tagging class.
32 33 34 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 32 def tagging_class_name @tagging_class_name end |
#transformer ⇒ Class (readonly)
Returns Tag string transformer.
14 15 16 |
# File 'lib/no_fly_list/taggable_record/tag_setup.rb', line 14 def transformer @transformer end |