Sha256: 24810b0d757a7e988c42c4074fc77d6813fb61896f79f4b05e6a9b03cc6af126

Contents?: true

Size: 564 Bytes

Versions: 12

Compression:

Stored size: 564 Bytes

Contents

module Machinist
  # Include this in a class to allow defining blueprints for that class.
  module Blueprints
    def self.included(base)
      base.extend(ClassMethods)
    end
    
    module ClassMethods
      def blueprint(name = :master, &blueprint)
        @blueprints ||= {}
        @blueprints[name] = blueprint if block_given?
        @blueprints[name]
      end
    
      def named_blueprints
        @blueprints.reject{|name,_| name == :master }.keys
      end
    
      def clear_blueprints!
        @blueprints = {}
      end
    end
    
  end
end

Version data entries

12 entries across 12 versions & 7 rubygems

Version Path
jdhollis-machinist-1.0.0 lib/machinist/blueprints.rb
jeremydurham-machinist-1.0.4 lib/machinist/blueprints.rb
lawrencepit-machinist-1.0.2 lib/machinist/blueprints.rb
lawrencepit-machinist-1.0.3 lib/machinist/blueprints.rb
notahat-machinist-1.0.0 lib/machinist/blueprints.rb
notahat-machinist-1.0.3 lib/machinist/blueprints.rb
pk-machinist-1.0.3 lib/machinist/blueprints.rb
JamieFlournoy-machinist-1.0.6 lib/machinist/blueprints.rb
machinist-1.0.6 lib/machinist/blueprints.rb
machinist-1.0.5 lib/machinist/blueprints.rb
machinist-1.0.4 lib/machinist/blueprints.rb
machinist-1.0.3 lib/machinist/blueprints.rb