Sha256: d73eb6571d7e343ee369e3d87cd87f09645d9311499e3a05ccfe7b4f5566c039

Contents?: true

Size: 404 Bytes

Versions: 8

Compression:

Stored size: 404 Bytes

Contents

module ModelHelpers
  def stub_model(name = nil, superclass = nil, &block)
    stub_class(name, superclass) { include Granite::Form::Model }.tap { |klass| klass.class_eval(&block) if block }
  end

  def stub_class(name = nil, superclass = nil, &block)
    klass = superclass ? Class.new(superclass, &block) : Class.new(&block)
    name.present? ? stub_const(name.to_s.camelize, klass) : klass
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
granite-form-0.6.1 spec/support/model_helpers.rb
granite-form-0.6.0 spec/support/model_helpers.rb
granite-form-0.5.0 spec/support/model_helpers.rb
granite-form-0.4.0 spec/support/model_helpers.rb
granite-form-0.3.0 spec/support/model_helpers.rb
granite-form-0.2.0 spec/support/model_helpers.rb
granite-form-0.1.1 spec/support/model_helpers.rb
granite-form-0.1.0 spec/support/model_helpers.rb