Browse files

Tucked module inheritable attributes in lib/httparty

  • Loading branch information...
1 parent c5e229b commit ef61a4afd113247be08643ee003462fec6d85be1 @jnunemaker committed Jan 31, 2009
Showing with 28 additions and 28 deletions.
  1. +3 −3 lib/httparty.rb
  2. +25 −0 lib/httparty/module_inheritable_attributes.rb
  3. +0 −25 lib/module_level_inheritable_attributes.rb
View
6 lib/httparty.rb
@@ -2,8 +2,8 @@
require 'net/http'
require 'net/https'
-require 'module_level_inheritable_attributes'
require 'core_extensions'
+require 'httparty/module_inheritable_attributes'
module HTTParty
@@ -19,7 +19,7 @@ module HTTParty
def self.included(base)
base.extend ClassMethods
- base.send :include, ModuleLevelInheritableAttributes
+ base.send :include, HTTParty::ModuleInheritableAttributes
base.send(:mattr_inheritable, :default_options)
base.instance_variable_set("@default_options", {})
end
@@ -129,9 +129,9 @@ def self.delete(*args)
end
end
+require 'httparty/cookie_hash'
require 'httparty/exceptions'
require 'httparty/request'
require 'httparty/response'
require 'httparty/json'
require 'httparty/xml'
-require 'httparty/cookie_hash'
View
25 lib/httparty/module_inheritable_attributes.rb
@@ -0,0 +1,25 @@
+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
View
25 lib/module_level_inheritable_attributes.rb
@@ -1,25 +0,0 @@
-module ModuleLevelInheritableAttributes #: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

0 comments on commit ef61a4a

Please sign in to comment.