Sha256: b880c6fc8c13679d7b882439111b653ace17174c71fe2c709dfd3eebb07202bd

Contents?: true

Size: 771 Bytes

Versions: 35

Compression:

Stored size: 771 Bytes

Contents

# encoding: utf-8

module Adhearsion
  class Plugin
    class Initializer
      attr_reader :name, :block

      def initialize(name, context, options, &block)
        options[:group] ||= :default
        @name, @context, @options, @block = name, context, options, block
      end

      def before
        @options[:before]
      end

      def after
        @options[:after]
      end

      def belongs_to?(group)
        @options[:group] == group || @options[:group] == :all
      end

      def run(*args)
        @context.instance_exec(*args, &block)
      end

      def bind(context)
        return self if @context
        Initializer.new @name, context, @options, &block
      end

      def to_s
        "#{self.name}: #{@options}"
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
adhearsion-2.6.4 lib/adhearsion/plugin/initializer.rb
adhearsion-2.6.3 lib/adhearsion/plugin/initializer.rb
adhearsion-3.0.0.rc1 lib/adhearsion/plugin/initializer.rb
adhearsion-3.0.0.beta2 lib/adhearsion/plugin/initializer.rb
adhearsion-3.0.0.beta1 lib/adhearsion/plugin/initializer.rb
adhearsion-2.6.2 lib/adhearsion/plugin/initializer.rb
adhearsion-2.6.1 lib/adhearsion/plugin/initializer.rb
adhearsion-2.6.0 lib/adhearsion/plugin/initializer.rb
adhearsion-2.5.4 lib/adhearsion/plugin/initializer.rb
adhearsion-2.5.3 lib/adhearsion/plugin/initializer.rb
adhearsion-2.5.2 lib/adhearsion/plugin/initializer.rb
adhearsion-2.5.0 lib/adhearsion/plugin/initializer.rb
adhearsion-2.4.0 lib/adhearsion/plugin/initializer.rb
adhearsion-2.4.0.beta3 lib/adhearsion/plugin/initializer.rb
adhearsion-2.4.0.beta2 lib/adhearsion/plugin/initializer.rb
adhearsion-2.4.0.beta1 lib/adhearsion/plugin/initializer.rb
adhearsion-2.3.5 lib/adhearsion/plugin/initializer.rb
adhearsion-2.3.4 lib/adhearsion/plugin/initializer.rb
adhearsion-2.3.3 lib/adhearsion/plugin/initializer.rb
adhearsion-2.3.2 lib/adhearsion/plugin/initializer.rb