Sha256: f49ca9481ec29d16f163f4a890b26d7c60c75e8d835fe03d2267f7930cf31377

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

module Answers
  module Engine
    # Specify a block of code to be run after the answers inclusion step. See
    # Answers::Core::Engine#answers_inclusion for details regarding the Answers
    # inclusion process.
    #
    # Example:
    #   module Answers
    #     module Images
    #       class Engine < Rails::Engine
    #         extend Answers::Engine
    #         engine_name :images
    #
    #         after_inclusion do
    #           # perform something here
    #         end
    #       end
    #     end
    #   end
    def after_inclusion(&block)
      if block && block.respond_to?(:call)
        after_inclusion_procs << block
      else
        raise 'Anything added to be called after_inclusion must be callable (respond to #call).'
      end
    end

    # Specify a block of code to be run before the answers inclusion step. See
    # Answers::Core::Engine#answers_inclusion for details regarding the Answers
    # inclusion process.
    #
    # Example:
    #   module Answers
    #     module Images
    #       class Engine < Rails::Engine
    #         extend Answers::Engine
    #         engine_name :images
    #
    #         before_inclusion do
    #           # perform something here
    #         end
    #       end
    #     end
    #   end
    def before_inclusion(&block)
      if block && block.respond_to?(:call)
        before_inclusion_procs << block
      else
        raise 'Anything added to be called before_inclusion must be callable (respond to #call).'
      end
    end

    private
    def after_inclusion_procs
      @@after_inclusion_procs ||= []
    end

    def before_inclusion_procs
      @@before_inclusion_procs ||= []
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
answers-core-0.0.0.2 lib/answers/engine.rb
answers-core-0.0.0 lib/answers/engine.rb