Class: NoFlyList::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/no_fly_list/taggable_record/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(taggable_class = nil) ⇒ Config

Returns a new instance of Config.



7
8
9
10
11
# File 'lib/no_fly_list/taggable_record/config.rb', line 7

def initialize(taggable_class = nil)
  @tag_contexts = {}
  @taggable_class = taggable_class
  @adapter = determine_adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



5
6
7
# File 'lib/no_fly_list/taggable_record/config.rb', line 5

def adapter
  @adapter
end

#tag_contextsObject (readonly)

Returns the value of attribute tag_contexts.



5
6
7
# File 'lib/no_fly_list/taggable_record/config.rb', line 5

def tag_contexts
  @tag_contexts
end

#taggable_classObject (readonly)

Returns the value of attribute taggable_class.



5
6
7
# File 'lib/no_fly_list/taggable_record/config.rb', line 5

def taggable_class
  @taggable_class
end

Instance Method Details

#add_context(context, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/no_fly_list/taggable_record/config.rb', line 13

def add_context(context, options = {})
  context = context.to_sym
  tag_class_name = determine_tag_class_name(options)
  tagging_class_name = determine_tagging_class_name(options)

  @tag_contexts[context] = {
    taggable_class: @taggable_class.to_s,
    tag_class_name: tag_class_name,
    tagging_class_name: tagging_class_name,
    transformer: options.fetch(:transformer, ApplicationTagTransformer).to_s,
    polymorphic: options.fetch(:polymorphic, false),
    restrict_to_existing: options.fetch(:restrict_to_existing, false),
    limit: options.fetch(:limit, nil),
    case_sensitive: options.fetch(:case_sensitive, true),
    adapter: @adapter,
    counter_cache: options.fetch(:counter_cache, false)
  }
end