@@ -135,7 +135,7 @@ module ClassMethods
135135 # expected API. It is recommended that your type objects inherit from an
136136 # existing type, or from ActiveRecord::Type::Value
137137 #
138- # class MoneyType < ActiveRecord::Type::Integer
138+ # class PriceType < ActiveRecord::Type::Integer
139139 # def cast(value)
140140 # if !value.kind_of?(Numeric) && value.include?('$')
141141 # price_in_dollars = value.gsub(/\$/, '').to_f
@@ -147,11 +147,11 @@ module ClassMethods
147147 # end
148148 #
149149 # # config/initializers/types.rb
150- # ActiveRecord::Type.register(:money, MoneyType )
150+ # ActiveRecord::Type.register(:price, PriceType )
151151 #
152152 # # app/models/store_listing.rb
153153 # class StoreListing < ActiveRecord::Base
154- # attribute :price_in_cents, :money
154+ # attribute :price_in_cents, :price
155155 # end
156156 #
157157 # store_listing = StoreListing.new(price_in_cents: '$10.00')
@@ -171,7 +171,7 @@ module ClassMethods
171171 # class Money < Struct.new(:amount, :currency)
172172 # end
173173 #
174- # class MoneyType < ActiveRecord::Type::Value
174+ # class PriceType < ActiveRecord::Type::Value
175175 # def initialize(currency_converter:)
176176 # @currency_converter = currency_converter
177177 # end
@@ -186,12 +186,12 @@ module ClassMethods
186186 # end
187187 #
188188 # # config/initializers/types.rb
189- # ActiveRecord::Type.register(:money, MoneyType )
189+ # ActiveRecord::Type.register(:price, PriceType )
190190 #
191191 # # app/models/product.rb
192192 # class Product < ActiveRecord::Base
193193 # currency_converter = ConversionRatesFromTheInternet.new
194- # attribute :price_in_bitcoins, :money , currency_converter: currency_converter
194+ # attribute :price_in_bitcoins, :price , currency_converter: currency_converter
195195 # end
196196 #
197197 # Product.where(price_in_bitcoins: Money.new(5, "USD"))
0 commit comments