Sha256: 4f9cf263d364ca3b6a603d9e8431ab358537e18ab30521a5db9332e4774c3165

Contents?: true

Size: 758 Bytes

Versions: 10

Compression:

Stored size: 758 Bytes

Contents

module Locomotive
  module Plugin
    module Liquid
      # @api internal
      #
      # Extension to liquid drops added by plugins.
      module DropExtension

        # Allow setting the plugin_id, but only once.
        def set_plugin_id(plugin_id)
          @_plugin_id ||= plugin_id
        end

        # Add the plugin object to the context when invoked (see
        # Liquid::Drop#invoke_drop)
        def invoke_drop(method)
          value = nil

          ContextHelpers.add_plugin_object_to_context(_plugin_id, @context) do
            value = super
          end

          value
        end
        alias :[] :invoke_drop

        private

        # Plugin ID (see set_plugin_id).
        attr_reader :_plugin_id

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
locomotive_plugins-1.2.0 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.1.1 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.1.0 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.0.1 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.0.0.beta10 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.0.0.beta9 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.0.0.beta8 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.0.0.beta7 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.0.0.beta6 lib/locomotive/plugin/liquid/drop_extension.rb
locomotive_plugins-1.0.0.beta5 lib/locomotive/plugin/liquid/drop_extension.rb