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



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

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



45
46
47
# File 'lib/spree/api.rb', line 45

def dependencies
  Spree::Api::Dependencies
end

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

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/spree/api.rb', line 39

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