Module: VShipping::Configuration::ClassMethods
- Defined in:
- lib/v_shipping/configuration.rb
Instance Method Summary collapse
- #add_config(name) ⇒ Object
- #add_deprecated_config(name) ⇒ Object
- #configure {|_self| ... } ⇒ Object
-
#reset_config ⇒ Object
sets configuration back to default.
Instance Method Details
#add_config(name) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/v_shipping/configuration.rb', line 14 def add_config(name) class_eval <<-RUBY, __FILE__, __LINE__ + 1 @#{name} = nil def self.#{name}(value=nil) @#{name} = value if value return @#{name} if self.object_id == #{self.object_id} || defined?(@#{name}) name = superclass.#{name} return nil if name.nil? && !instance_variable_defined?(:@#{name}) @#{name} = name && !name.is_a?(Module) && !name.is_a?(Symbol) && !name.is_a?(Numeric) && !name.is_a?(TrueClass) && !name.is_a?(FalseClass) ? name.dup : name end def self.#{name}=(value) @#{name} = value end def #{name}=(value) @#{name} = value end def #{name} value = @#{name} if instance_variable_defined?(:@#{name}) value = self.class.#{name} unless instance_variable_defined?(:@#{name}) if value.instance_of?(Proc) value.arity >= 1 ? value.call(self) : value.call else value end end RUBY end |
#add_deprecated_config(name) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/v_shipping/configuration.rb', line 42 def add_deprecated_config(name) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def self.#{name}(value=nil) ActiveSupport::Deprecation.warn "##{name} is deprecated and has no effect" end def self.#{name}=(value) ActiveSupport::Deprecation.warn "##{name} is deprecated and has no effect" end def #{name}=(value) ActiveSupport::Deprecation.warn "##{name} is deprecated and has no effect" end def #{name} ActiveSupport::Deprecation.warn "##{name} is deprecated and has no effect" end RUBY end |
#configure {|_self| ... } ⇒ Object
59 60 61 |
# File 'lib/v_shipping/configuration.rb', line 59 def configure yield self end |
#reset_config ⇒ Object
sets configuration back to default
66 67 68 69 70 71 |
# File 'lib/v_shipping/configuration.rb', line 66 def reset_config configure do |config| config.ahamove_api_key = nil config.ahamove_config_path = nil end end |