Class: URL::Service
- Inherits:
-
Object
- Object
- URL::Service
- Extended by:
- AcceptsEndpoint
- Defined in:
- lib/url/service.rb,
lib/url/endpoint.rb,
lib/url/accepts_endpoint.rb,
lib/url/endpoint_builder.rb
Defined Under Namespace
Modules: AcceptsEndpoint Classes: Endpoint, EndpointBuilder
Constant Summary collapse
- INHERITED_INSTANCE_VARIABLES =
{:@base_url=>:dup}
Class Attribute Summary collapse
-
.config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Methods included from AcceptsEndpoint
Class Attribute Details
.config ⇒ Object
Returns the value of attribute config.
11 12 13 |
# File 'lib/url/service.rb', line 11 def config @config end |
Class Method Details
.inherited(subclass) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/url/service.rb', line 20 def inherited(subclass) super if defined?(Rails) && File.exist?(Rails.root+'config/services.yml') self.config ||= YAML.load_file(Rails.root+'config/services.yml')[Rails.env] rescue nil if config target_name = subclass.to_s.demodulize.underscore service_url = config[target_name]||config[target_name.sub(/_service$/,'')] end end if service_url subclass.set_url service_url end ivs = subclass.instance_variables.collect{|x| x.to_s} INHERITED_INSTANCE_VARIABLES.each do |iv,dup| next if ivs.include?(iv.to_s) sup_class_value = instance_variable_get(iv) sup_class_value = sup_class_value.dup if dup == :dup && sup_class_value subclass.instance_variable_set(iv, sup_class_value) end end |