Project

General

Profile

How to override the model method visible_condition

Added by Kamal Chabi about 9 years ago

I want to override the model method with my plugin. I tried to create a new model Patch with method that should override like this:

    require_dependency 'issue'

    module IssuePatch
        def self.included(base) # :nodoc:
            base.send(:extend, ClassMethods)
            base.send(:include, InstanceMethods)
            base.class_eval do
                alias_method :visible_condition, :visible_condition_with_patch
            end
        end

        module ClassMethods

        end

        module InstanceMethods
            def visible_condition_with_patch(user, options={})

                <Do Something>
            end
          end
    end

    Rails.configuration.to_prepare do
        unless Issue.included_modules.include? IssuePatch
            # Issue.extend(InstanceMethods)
            Issue.send(:include, IssuePatch)
        end
    end