1. 24 1月, 2018 1 次提交
    • S
      Allow attributes with a proc default to be marshalled · 0af36c62
      Sean Griffin 提交于
      We don't implement much custom marshalling logic for these objects, but
      the proc default case needs to be handled separately. Unfortunately
      there's no way to just say "do what you would have done but with this
      value for one ivar", so we have to manually implement `marshal_load` as
      well.
      
      The test case is a little bit funky, but I'd really like an equality
      test in there, and there's no easy way to add one now that this is out
      of AR (since the `attributes` method isn't here)
      
      Fixes #31216
      0af36c62
  2. 15 12月, 2017 1 次提交
    • Y
      Suppress `warning: BigDecimal.new is deprecated` in Active Model · bd4211ea
      Yasuo Honda 提交于
      `BigDecimal.new` has been deprecated in BigDecimal 1.3.3
       which will be a default for Ruby 2.5.
      
      Refer ruby/bigdecimal@5337373
      
      * This commit has been made as follows:
      
      ```ruby
      $ cd activemodel/
      $ git grep -l BigDecimal.new | grep \.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g"
      ```
      
      * This commit has been tested with these Ruby versions:
      
      ```
      ruby 2.5.0dev (2017-12-15 trunk 61262) [x86_64-linux]
      ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
      ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-linux]
      ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-linux]
      ```
      bd4211ea
  3. 10 11月, 2017 1 次提交
  4. 19 10月, 2017 1 次提交
    • L
      Start bringing attributes API to AM · 7e9ded51
      Lisa Ugray 提交于
      This is the first PR of a WIP to bring the attributes API to
      ActiveModel.  It is not yet ready for public API.
      
      The `attributes_dirty_test.rb` file was created based on `dirty_test.rb`,
      and the simplifications in the diff do much to motivate this change.
      
      ```
      diff activemodel/test/cases/dirty_test.rb activemodel/test/cases/attributes_dirty_test.rb
      3a4
      > require "active_model/attributes"
      5c6
      < class DirtyTest < ActiveModel::TestCase
      ---
      > class AttributesDirtyTest < ActiveModel::TestCase
      7,41c8,12
      <     include ActiveModel::Dirty
      <     define_attribute_methods :name, :color, :size
      <
      <     def initialize
      <       @name = nil
      <       @color = nil
      <       @size = nil
      <     end
      <
      <     def name
      <       @name
      <     end
      <
      <     def name=(val)
      <       name_will_change!
      <       @name = val
      <     end
      <
      <     def color
      <       @color
      <     end
      <
      <     def color=(val)
      <       color_will_change! unless val == @color
      <       @color = val
      <     end
      <
      <     def size
      <       @size
      <     end
      <
      <     def size=(val)
      <       attribute_will_change!(:size) unless val == @size
      <       @size = val
      <     end
      ---
      >     include ActiveModel::Model
      >     include ActiveModel::Attributes
      >     attribute :name, :string
      >     attribute :color, :string
      >     attribute :size, :integer
      ```
      7e9ded51
  5. 21 7月, 2009 1 次提交
  6. 18 6月, 2009 1 次提交