Class: SharingTags::Config

Inherits:
Hashie::Mash
  • Object
show all
Defined in:
lib/sharing_tags/config.rb

Instance Method Summary collapse

Instance Method Details

#divide_by_keys(lists) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sharing_tags/config.rb', line 13

def divide_by_keys(lists)
  second_part = self.class.new

  lists.each do |divide_key|
    second_part[divide_key] =
        if self.key?(divide_key)
          delete(divide_key)
        else
          self.class.new
        end
  end

  [second_part, self]
end

#get(*keys) ⇒ Object



28
29
30
# File 'lib/sharing_tags/config.rb', line 28

def get(*keys)
  dup.select { |key, _| keys.include?(key.to_sym) }
end

#switch_context_to(name, *attrs) ⇒ Object

NOTE: temporary code for working construction sharing_tags.switch_context_to



8
9
10
11
# File 'lib/sharing_tags/config.rb', line 8

def switch_context_to(name, *attrs)
  Rails.logger.debug "SharingTags: switch context from #{SharingTags.config.current_context.name} to #{name}"
  SharingTags.config.switch_context(name, *attrs)
end