aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/test/cases/attributes_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Revert "No such class since 8d2866bb80fbe81acb04f5b0c44f152f571fb29f"Rafael Mendonça França2019-08-021-1/+1
| | | | This reverts commit dd779c9686f49f5ed6dda8ad5a1cb3b0788e1dd4.
* No such class since 8d2866bb80fbe81acb04f5b0c44f152f571fb29fAkira Matsuda2019-08-021-1/+1
|
* Add attribute_names to ActiveModel::AttributesDaniel Colson2019-04-221-0/+14
| | | | | | | | | | | | | | | This adds `.attribute_names` and `#attribute_names` to `ActiveModel::Attributes` along the same lines as the corresponding methods in `ActiveRecord::AttributeMethods` (see [`.attribute_names`][class_method] and [`#attribute_names`][instance_method]. While I was here I also added documentation for '#attributes', which I added in 043ce35b186. The whole class is still `#:nodoc:` so I don't think this will have any effect for now. [class_method]: https://github.com/rails/rails/blob/cc834db1d0815744cfa173813c05d928e008e167/activerecord/lib/active_record/attribute_methods.rb#L154-L160 [instance_method]: https://github.com/rails/rails/blob/cc834db1d0815744cfa173813c05d928e008e167/activerecord/lib/active_record/attribute_methods.rb#L299-L301
* Add ActiveModel::Attributes#attributesDaniel Colson2018-02-071-0/+20
| | | | | | This starts to fix #31832. ActiveModel::Attributes includes ActiveModel::AttributeMethods, which requires an `#attributes` method that returns a hash with string keys.
* Allow attributes with a proc default to be marshalledSean Griffin2018-01-231-0/+9
| | | | | | | | | | | | | | 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
* Suppress `warning: BigDecimal.new is deprecated` in Active ModelYasuo Honda2017-12-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | `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] ```
* Move Attribute and AttributeSet to ActiveModelLisa Ugray2017-11-091-27/+1
| | | | | Use these to back the attributes API. Stop automatically including ActiveModel::Dirty in ActiveModel::Attributes, and make it optional.
* Start bringing attributes API to AMLisa Ugray2017-10-181-0/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 ```
* Kill AMo ivar attributes helperJoshua Peek2009-07-201-30/+0
|
* Add simple attribute implementation backed by ivarsJoshua Peek2009-06-171-0/+30