Sha256: ba934e2631689fe815c8745191a1cd2ea612e7cfaa22c9b78af14c5cab834b39

Contents?: true

Size: 832 Bytes

Versions: 2

Compression:

Stored size: 832 Bytes

Contents

module Rails
  module Generator
    class GeneratedAttribute
      def default_value
        @default_value ||= case type
          when :int, :integer               then "1"
          when :float                       then "1.5"
          when :decimal                     then "9.99"
          when :datetime, :timestamp, :time then "Time.now"
          when :date                        then "Date.today"
          when :string, :text               then "\"value for #{@name}\""
          when :boolean                     then "false"
          when :belongs_to, :references     then "1"
          else
            ""
          end
      end

      def name_or_reference
        if ::Rails::VERSION::STRING >= '2.2'
          reference? ? :"#{name}_id" : name
        else
          name
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-rails-w-factory_girl-1.3.2.1 generators/rspec_default_values.rb
rspec-rails-w-factory_girl-1.3.2 generators/rspec_default_values.rb