I use Spree Commerce for my online store. I want to change some behavior during the verification process, which is defined in app/models/spree/order/checkout.rb inside the spree gem. So I did checkout_decorator.rb at the same point in the application.
The problem is that my changes are not uploaded. And another problem is that everything inside the module is inside one method, def self.included(klass) method. Therefore, I think I should overwrite the entire file, not just one method. Here's what my decorator looks like:
checkout_decorator.rb
Spree::Order::Checkout.module_eval do def self.included(klass) klass.class_eval do class_attribute :next_event_transitions class_attribute :previous_states class_attribute :checkout_flow class_attribute :checkout_steps def self.define_state_machine!
The original spree gemstone checkout.rb as follows:
module Spree class Order < ActiveRecord::Base module Checkout def self.included(klass) klass.class_eval do class_attribute :next_event_transitions class_attribute :previous_states class_attribute :checkout_flow class_attribute :checkout_steps def self.checkout_flow(&block) if block_given? @checkout_flow = block define_state_machine! else @checkout_flow end end def self.define_state_machine! # some code end # and other methods that are not shown here end end end end end
So my questions are: why doesn't this work? Is module_eval right way to do this? I tried class_eval but it doesn't work either. How can i solve this?
23tux source share