Sha256: 9933ae940c26aafe34aba13eb3c8a7dc7b73d942afaa0ca0dd220ddd3aec78c6

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 Bytes

Contents

module Firebrew
  module Entity
    def self.included(base)
      base.class_eval do
        extend ClassMethod
      end
    end
    
    module ClassMethod
      attr_accessor :attributes
      
      def self.extended(base)
        base.attributes = []
      end
      
      def inherited(base)
        base.attributes = self.attributes.clone
      end
      
      def entity_attr(*attrs)
        attrs.uniq!
        common = self.attributes & attrs
        adding = attrs - common
        self.attributes.push(*adding)
        attr_accessor *adding
        adding
      end
    end
    
    def ==(rop)
      self.class.attributes.each do |attr|
        return false unless self.send(attr) == rop.send(attr)
      end
      return true
    end
    
    alias :eql? :==
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
firebrew-0.1.3 lib/firebrew/entity.rb
firebrew-0.1.2 lib/firebrew/entity.rb
firebrew-0.1.1 lib/firebrew/entity.rb
firebrew-0.1.0 lib/firebrew/entity.rb