Sha256: d881cd4f8f1a73fa6c180b58a0df021f805837b2316b7b15151d78c417ebdaf9
Contents?: true
Size: 1.66 KB
Versions: 3
Compression:
Stored size: 1.66 KB
Contents
module SharingTags class Configuration NETWORKS = %i{ google facebook twitter } def initialize clear! end def context(name, &block) raise "please define context block params" unless block_given? (@contexts[name] ||= Context.new(name, self)).instance_exec(&block) end def switch_context(name = nil, *args) clean_params! @current_context_params = args @prev_context = current_context @current_context = if name @contexts[name] else default_context end end alias switch_context_to switch_context def clear! @contexts = {} @default_context = Context.new(:default, self) @current_context = nil @running_context = nil clean_params! end def params # @params ||= fetch_params @params = fetch_params end def within_context_params(running_context_instance) @running_context = running_context_instance params end def running_context @running_context end def current_context @current_context || default_context end def clean_params! @params = nil end def clear_context! @current_context = nil end private def fetch_params default_context_params = default_context.params(@current_context_params) return default_context_params unless @current_context @current_context.params(@current_context_params, default_context_params) end def method_missing(method_name, *arguments, &block) current_context.send(method_name, *arguments, &block) end def default_context @default_context end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sharing_tags-0.0.4 | lib/sharing_tags/configuration.rb |
sharing_tags-0.0.3 | lib/sharing_tags/configuration.rb |
sharing_tags-0.0.2 | lib/sharing_tags/configuration.rb |