Sha256: 6dd5a2bca512fe040f54c67dd0d0b4d5020512905f29a2d8906357288efc4483

Contents?: true

Size: 722 Bytes

Versions: 2

Compression:

Stored size: 722 Bytes

Contents

module InheritableAccessors
  module InheritableSetAccessor
    extend ActiveSupport::Concern

    module ClassMethods
      def inheritable_set_accessor(name)
        name = name.to_s

        module_eval <<-METHODS
          def self.inheritable_set?
            true
          end

          def self.#{name}
            @__#{name}__ ||= begin
              if superclass.respond_to?(:inheritable_set?)
                superclass.#{name}.inherit_copy
              else
                ::InheritableAccessors::InheritableSet.new
              end
            end
          end

          def #{name}
            @__#{name}__ ||= self.class.#{name}.inherit_copy
          end
        METHODS
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
inheritable_accessors-0.1.2 lib/inheritable_accessors/inheritable_set_accessor.rb
inheritable_accessors-0.1.1 lib/inheritable_accessors/inheritable_set_accessor.rb