Sha256: 1241834a3d4d341a1e6fab4c4a5647571bdf097e92542d1dc78978e362faf77f

Contents?: true

Size: 830 Bytes

Versions: 24

Compression:

Stored size: 830 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

24 entries across 24 versions & 7 rubygems

Version Path
Objective3-objective_spec-0.0.4 generators/rspec_default_values.rb
Objective3-objective_spec-0.1.2 generators/rspec_default_values.rb
Objective3-objective_spec-0.1.3 generators/rspec_default_values.rb
Objective3-objective_spec-0.1.4 generators/rspec_default_values.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/rspec-rails-1.3.4/generators/rspec_default_values.rb
richzhou-rspec-rails-1.3.4 generators/rspec_default_values.rb
rspec-rails-1.3.4 generators/rspec_default_values.rb
rspec-rails-1.3.3 generators/rspec_default_values.rb
rspec-rails-1.3.3.rc generators/rspec_default_values.rb
exception2db-0.0.1 test/rspec-rails/generators/rspec_default_values.rb
objective_spec-0.3.1 generators/rspec_default_values.rb
rspec-rails-1.3.2 generators/rspec_default_values.rb
rspec-rails-1.3.1 generators/rspec_default_values.rb
rspec-rails-1.3.0 generators/rspec_default_values.rb
hubbub-0.0.11 lib/vendor/plugins/rspec-rails/generators/rspec_default_values.rb
hubbub-0.0.10 lib/vendor/plugins/rspec-rails/generators/rspec_default_values.rb
hubbub-0.0.9 lib/vendor/plugins/rspec-rails/generators/rspec_default_values.rb
hubbub-0.0.8 lib/vendor/plugins/rspec-rails/generators/rspec_default_values.rb
hubbub-0.0.6 lib/vendor/plugins/rspec-rails/generators/rspec_default_values.rb
objective_spec-0.3.0 generators/rspec_default_values.rb