Class: Spree::ApiDependenciesAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/spree/api.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/spree/api.rb', line 24

def method_missing(method_name, *args, &block)
  base_name = method_name.to_s.chomp('=').to_sym

  return super unless api_dependency?(base_name)

  if method_name.to_s.end_with?('=')
    Spree::Api::Dependencies.send(method_name, args.first)
  else
    # Returns resolved class
    Spree::Api::Dependencies.send("#{method_name}_class")
  end
end

Instance Method Details

#dependenciesObject

Direct access to raw dependencies object for backwards compatibility



43
44
45
# File 'lib/spree/api.rb', line 43

def dependencies
  Spree::Api::Dependencies
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/spree/api.rb', line 37

def respond_to_missing?(method_name, include_private = false)
  base_name = method_name.to_s.chomp('=').to_sym
  api_dependency?(base_name) || super
end