Sha256: 0bc8318c7d6dc6aa4f7dbcee4373dcb0ff9c7044ab6937a827d56933cf0e45dd

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

Stored size: 968 Bytes

Contents

# encoding: UTF-8

module Watchmaker
  module Learner
    extend ActiveSupport::Concern

    module ClassMethods

      # Learn a profile by taking explicit dependencies.
      #
      def learn(name, dependencies = {}, &block)

        if name.is_a?(Hash)
          
          # Convert the hash into a profile name and a list of
          # dependencies that's either a hash of nested classes or
          # array.
          #
          name, dependencies = 
            name_and_dependencies_from_dependency_hash(name) 

          # Specifically store these as abstract dependencies.
          #
          dependencies = { :abstract => dependencies }

        end

        Configuration.learn(name, dependencies, &block)
      end

      # Get the profile name out of a dependency hash.
      #
      def name_and_dependencies_from_dependency_hash(dependencies)
        name = dependencies.keys.first
        [name, dependencies[name]]
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
watchmaker-0.1.2 lib/watchmaker/learner.rb
watchmaker-0.1.1 lib/watchmaker/learner.rb
watchmaker-0.1.0 lib/watchmaker/learner.rb