Sha256: 879aac6dbafaf5748db234fc4a8f4ddc5f759aaef07e4b0af2ac9a447e427e93

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

module Blueprints
  # Module that blueprints file is executed against. Defined <tt>blueprint</tt> and <tt>namespace</tt> methods.
  module FileContext
    mattr_accessor :evaluating

    # Creates a new blueprint by name and block passed
    def self.blueprint(name, &block)
      Blueprint.new(name, &block)
    end

    # Creates new namespace by name, and evaluates block against it.
    def self.namespace(name)
      old_namespace = Namespace.root
      namespace = Namespace.new(name)
      Namespace.root = namespace
      yield
      old_namespace.add_child(namespace)
      Namespace.root = old_namespace
      namespace
    end

    # Creates dependency for current blueprint on some other blueprint and marks that instance variable with same name
    # should be used for value of column. Only works on "Class.blueprint :name" type of blueprints
    def self.d(name)
      Buildable::Dependency.new(name)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blueprints-0.7.2 lib/blueprints/file_context.rb
blueprints-0.7.1 lib/blueprints/file_context.rb