Sha256: b6aae3e94d6db4213b0898d65399bad15b8056b9e434b430410002c5d03666e2
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module TrackChanges # A Result instance is yielded by ClassMethods#track_changes_to. # # Example: # # track_changes_to :post do |result| # result.post # => The instance variable in the current_controler # # given by the :post option. # result.controller # => The instance of the current controller # result.current_user # => The current controllers @current_user # result.some_method # => Call some_method on the current controller instance # end class Result attr_accessor :changes, :controller def initialize(model_name, controller, changes) @changes = changes @controller = controller self.class.send(:define_method, model_name) do @controller.instance_variable_get("@#{model_name}") end end # Pass all other methods to the controller. def method_missing(method_sym, *args) controller.send(method_sym, *args) end # A convienence method that returns the <tt>@current_user</tt> # in the current controller. def current_user user = controller.instance_variable_get("@current_user") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
track_changes-0.5.1 | lib/track_changes/result.rb |