Sha256: 059d6a9f635418a5cca79f028ad968458aec54d2a527c6c8a2dd57081f0cb249

Contents?: true

Size: 679 Bytes

Versions: 3

Compression:

Stored size: 679 Bytes

Contents

module Automigration
  class Dsl
    attr_reader :fields
    attr_reader :devise_fields

    def initialize
      @fields = []
      @devise_fields = []
    end

    Field::KIND.each do |field|
      define_method field do |*args|
        options = args.extract_options!
        raise "wrong amount of args" unless args.size == 1
        name = args[0]
        @fields << {:name => name, :as => field.to_sym}.merge(options)
        Field.valid_options_keys(@fields.last)
      end
    end

    def method_missing(meth, *args, &block)
      if meth.to_s =~ /^devise_(.*)/
        @devise_fields << {:as => meth, :args => args}
      else
        super
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
automigration-1.0.2 lib/automigration/dsl.rb
automigration-1.0.1 lib/automigration/dsl.rb
automigration-1.0.0 lib/automigration/dsl.rb