Shopify / measured-rails

Rails adapter for the measured gem. Encapsulate measurements and their units in Ruby and Rails.
MIT License
92 stars 13 forks source link

Change implementation to attributes API #34

Open kmcphillips opened 7 years ago

kmcphillips commented 7 years ago

This API has been public since rails 5.0: http://api.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute

Up sides: It would greatly simplify the implementation. It would work with ActiveModel objects.

Down sides: It's not implemented in ActiveModel yet.

cc @thegedge

thegedge commented 7 years ago

In combination with http://api.rubyonrails.org/classes/ActiveRecord/Aggregations/ClassMethods.html#method-i-composed_of I think we could greatly simplify things here. I'd be fine having an include-able module for ActiveModel, until it also supports the attribute API.