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.3.1 lib/adhearsion/plugin/initializer.rb
adhearsion-2.3.0 lib/adhearsion/plugin/initializer.rb
adhearsion-2.2.1 lib/adhearsion/plugin/initializer.rb
adhearsion-2.2.0 lib/adhearsion/plugin/initializer.rb
adhearsion-2.1.3 lib/adhearsion/plugin/initializer.rb
adhearsion-2.1.2 lib/adhearsion/plugin/initializer.rb
adhearsion-2.1.1 lib/adhearsion/plugin/initializer.rb
adhearsion-2.1.0 lib/adhearsion/plugin/initializer.rb
adhearsion-2.0.1 lib/adhearsion/plugin/initializer.rb
adhearsion-2.0.0 lib/adhearsion/plugin/initializer.rb
adhearsion-2.0.0.rc5 lib/adhearsion/plugin/initializer.rb
adhearsion-2.0.0.rc4 lib/adhearsion/plugin/initializer.rb
adhearsion-2.0.0.rc3 lib/adhearsion/plugin/initializer.rb
adhearsion-2.0.0.rc2 lib/adhearsion/plugin/initializer.rb
adhearsion-2.0.0.rc1 lib/adhearsion/plugin/initializer.rb