Sha256: 48352990a845017f4e7b04460fb30cbc1825a2968323f6247b15c805f287c963

Contents?: true

Size: 693 Bytes

Versions: 1

Compression:

Stored size: 693 Bytes

Contents

require 'active_support/concern'

module SimpleMachinable
  extend ActiveSupport::Concern

  class SimpleBlueprint < Machinist::Blueprint
    def make!(attributes={})
      make(attributes).tap(&:save!)
    end
  end

  included do
    extend Machinist::Machinable
    # ClassMethods is included *before* the included block, so blueprint_class
    # would be overriden by the extend if it were in the ClassMethods module
    class_eval do
      def self.blueprint_class
        SimpleBlueprint
      end
    end
  end

  def self.ensure_machinable(*klasses)
    klasses.each do |klass|
      next if klass.respond_to?(:blueprint)
      klass.send(:include, SimpleMachinable)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
circuit-0.2.0 spec/support/spec_helpers/simple_machinable.rb