Sha256: 908aa79c9325c79bd89ff774bebe5937886559a9be6908f10b19298b4c6a604b

Contents?: true

Size: 835 Bytes

Versions: 8

Compression:

Stored size: 835 Bytes

Contents

require "hashie/mash"

module SharingTags
  class Config < ::Hashie::Mash

    # todo: initialize default param as Config.new

    # note: temporary code for working construction sharing_tags.switch_context_to
    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

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

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

      [second_part, self]
    end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sharing_tags-0.0.9 lib/sharing_tags/config.rb
sharing_tags-0.0.8 lib/sharing_tags/config.rb
sharing_tags-0.0.7 lib/sharing_tags/config.rb
sharing_tags-0.0.6 lib/sharing_tags/config.rb
sharing_tags-0.0.5 lib/sharing_tags/config.rb
sharing_tags-0.0.4 lib/sharing_tags/config.rb
sharing_tags-0.0.3 lib/sharing_tags/config.rb
sharing_tags-0.0.2 lib/sharing_tags/config.rb