Sha256: 64b87ffde264440eb3526843455f06db826bbd98ebf395d57a0402a64f1f5f10

Contents?: true

Size: 893 Bytes

Versions: 1

Compression:

Stored size: 893 Bytes

Contents

module Aspect4r
  module Model
    class AdvicesForMethod
      attr_reader :method
      attr_accessor :wrapped_method
    
      def initialize method
        @method = method
      end
    
      def advices
        @advices ||= []
      end
    
      def add new_advice
        advices << new_advice unless include?(new_advice)
      end
    
      def empty?
        @advices.nil? or @advices.empty?
      end
    
      def include? new_advice
        advices.detect { |advice| advice.name == new_advice.name }
      end
    
      def merge! another
        unless another.nil? or another.empty?
          another.advices.each do |advice|
            advices.push advice unless include?(advice)
          end
        end

        self
      end
    
      def clone
        o = self.class.new(method)
        o.advices.push *advices unless empty?

        o
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aspect4r-0.7.1 lib/aspect4r/model/advices_for_method.rb