I am using Spree, and Spree has a class called Order
that looks like:
module Spree
class Order
# class definition.
end
end
In my own app, I have been customising Order
like so:
Spree::Order.class_eval do
# customisations
end
My question is, can I simply just do this:
module Spree
class Order
# My own customisations.
end
end
Any downsides to this? Essentially, I want to avoid using class_eval
.
class_eval
somehow isn't working for constants, and without class_eval, I can't figure out how to access other methods in the class that I am reopening. – Recreant@@some_constant
. Not a Spree issue, but a general Ruby weirdness. – Johnsenrequire
the module/class that I was opening prior to opening it. This ensured that the original class file was loaded before I opened it again to change it to avoid getting class not found errors. – Recreant