Sha256: 7db34e44943fb10a4319635aaccbda86cc940d0eb0271ab0bb99f37d37949aab

Contents?: true

Size: 1.19 KB

Versions: 8

Compression:

Stored size: 1.19 KB

Contents

module Netzke
  module Inheritance
    extend ActiveSupport::Concern

    module ClassMethods
      # All ancestor classes in the Netzke class hierarchy (i.e. up to Netzke::Base)
      def class_ancestors
        if self == Netzke::Base
          []
        else
          superclass.class_ancestors + [self]
        end
      end

      # Same as +read_inheritable_attribute+ returning a hash, but returns empty hash when it's equal to superclass's
      def read_clean_inheritable_hash(attr_name)
        res = read_inheritable_attribute(attr_name) || {}
        # We don't want here any values from the superclass (which is the consequence of using inheritable attributes).
        res == self.superclass.read_inheritable_attribute(attr_name) ? {} : res
      end

      # Same as +read_inheritable_attribute+ returning a hash, but returns empty hash when it's equal to superclass's
      def read_clean_inheritable_array(attr_name)
        res = read_inheritable_attribute(attr_name) || []
        # We don't want here any values from the superclass (which is the consequence of using inheritable attributes).
        res == self.superclass.read_inheritable_attribute(attr_name) ? [] : res
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
netzke-core-0.7.5 lib/netzke/inheritance.rb
netzke-core-0.7.4 lib/netzke/inheritance.rb
netzke-core-0.7.3 lib/netzke/inheritance.rb
netzke-core-0.7.2 lib/netzke/inheritance.rb
netzke-core-0.7.1 lib/netzke/inheritance.rb
netzke-core-0.6.7 lib/netzke/inheritance.rb
netzke-core-0.7.0 lib/netzke/inheritance.rb
netzke-core-0.6.6 lib/netzke/inheritance.rb