Sha256: c71bdf14c650649cf7ab9f4692b577fa2fe6508953d8879d49f56604bf509fd2

Contents?: true

Size: 500 Bytes

Versions: 23

Compression:

Stored size: 500 Bytes

Contents

module Lookbook
  class HookStore
    CONFIG_FILE = "config/hooks.yml"

    attr_reader :store
    delegate :to_h, to: :store

    def initialize(config = nil)
      @store = {}
    end

    def add_hook(event_name, callback)
      for_event(event_name) << callback
    end

    def for_event(event_name)
      store[event_name.to_sym] ||= []
    end

    def self.init_from_config
      new(default_config)
    end

    def self.default_config
      ConfigLoader.call(CONFIG_FILE)
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
lookbook-1.5.5 lib/lookbook/stores/hook_store.rb
lookbook-1.5.4 lib/lookbook/stores/hook_store.rb
lookbook-2.0.0.beta.4 lib/lookbook/stores/hook_store.rb
lookbook-2.0.0.beta.3 lib/lookbook/stores/hook_store.rb
lookbook-2.0.0.beta.2 lib/lookbook/stores/hook_store.rb
lookbook-1.5.3 lib/lookbook/stores/hook_store.rb
lookbook-2.0.0.beta.1 lib/lookbook/stores/hook_store.rb
lookbook-1.5.2 lib/lookbook/stores/hook_store.rb
lookbook-2.0.0.beta.0 lib/lookbook/stores/hook_store.rb
lookbook-1.5.1 lib/lookbook/stores/hook_store.rb
lookbook-1.5.0 lib/lookbook/stores/hook_store.rb
lookbook-1.4.5 lib/lookbook/stores/hook_store.rb
lookbook-1.4.4 lib/lookbook/stores/hook_store.rb
lookbook-1.4.3 lib/lookbook/stores/hook_store.rb
lookbook-1.4.2 lib/lookbook/stores/hook_store.rb
lookbook-1.4.1 lib/lookbook/stores/hook_store.rb
lookbook-1.4.0 lib/lookbook/stores/hook_store.rb
lookbook-1.3.4 lib/lookbook/stores/hook_store.rb
lookbook-1.3.3 lib/lookbook/stores/hook_store.rb
lookbook-1.3.1 lib/lookbook/stores/hook_store.rb