Sha256: e8827fec9da766b2c750deb0b1d0e249e457f19a2f0457ffb3a1bf37030ac448

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'makers/callbacks'
require 'makers/definitions'
require 'makers/configuration'
require 'makers/maker'
require 'makers/sequence'
require 'makers/fetcher'
require 'makers/proxy'
require 'makers/methods'
require 'makers/railtie'

module Makers
  extend Methods
  class << self

    def reset
      configuration.reset
      definitions.reset
    end

    def configure(&block)
      configuration.instance_eval &block
    end

    def configuration
      @configuration ||= Configuration.new
    end

    def define(&block)
      definitions.instance_eval &block
    end

    def definitions
      @definitions ||= Definitions.new
    end

    def clean
      records.pop.destroy until records.empty?
    end

    def records
      @records ||= []
    end

    def load
      if path
        Dir[path.join('**', '*.rb')].each do |file|
          definitions.instance_eval File.read(file)
        end
      end
    end

    def path
      @path ||= %w(test spec).map{ |dir| Rails.root.join(dir) }.find{ |path| Dir.exist?(path) }.try(:join, 'makers')
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
makers-0.1.3 lib/makers.rb
makers-0.1.2 lib/makers.rb