Sha256: f43b05944729a61049f5b58020e4031a80ebca2d541715aa4bcdd075e4863e33

Contents?: true

Size: 733 Bytes

Versions: 48

Compression:

Stored size: 733 Bytes

Contents

module HTTParty
  module ModuleInheritableAttributes #:nodoc:
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods #:nodoc:
      def mattr_inheritable(*args)
        @mattr_inheritable_attrs ||= [:mattr_inheritable_attrs]
        @mattr_inheritable_attrs += args
        args.each do |arg|
          module_eval %(class << self; attr_accessor :#{arg} end)
        end
        @mattr_inheritable_attrs
      end

      def inherited(subclass)
        @mattr_inheritable_attrs.each do |inheritable_attribute|
          instance_var = "@#{inheritable_attribute}" 
          subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 16 rubygems

Version Path
alexvollmer-httparty-0.3.1 lib/httparty/module_inheritable_attributes.rb
alexvollmer-httparty-0.4.3 lib/httparty/module_inheritable_attributes.rb
cluon-httparty-0.4.3 lib/httparty/module_inheritable_attributes.rb
dbalatero-httparty-0.4.4 lib/httparty/module_inheritable_attributes.rb
ddollar-httparty-0.4.6 lib/httparty/module_inheritable_attributes.rb
geetarista-httparty-0.4.5 lib/httparty/module_inheritable_attributes.rb
jcinnamond-httparty-0.4.5 lib/httparty/module_inheritable_attributes.rb
jcinnamond-httparty-0.4.6 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.3.0 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.3.1 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.4.0 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.4.1 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.4.2 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.4.3 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.4.4 lib/httparty/module_inheritable_attributes.rb
jnunemaker-httparty-0.4.5 lib/httparty/module_inheritable_attributes.rb
kerryb-httparty-0.3.2 lib/httparty/module_inheritable_attributes.rb
kerryb-httparty-0.3.3 lib/httparty/module_inheritable_attributes.rb
kerryb-httparty-0.4.3 lib/httparty/module_inheritable_attributes.rb
leh-httparty-0.3.1.1 lib/httparty/module_inheritable_attributes.rb