Class: Phantasma::API::Request
- Inherits:
-
Object
- Object
- Phantasma::API::Request
- Defined in:
- lib/phantasma/API/request.rb
Instance Attribute Summary collapse
-
#api_version ⇒ Object
Returns the value of attribute api_version.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url:, api_version: 'v1', debug: false) ⇒ Request
constructor
A new instance of Request.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(url:, api_version: 'v1', debug: false) ⇒ Request
Returns a new instance of Request.
13 14 15 16 17 18 |
# File 'lib/phantasma/API/request.rb', line 13 def initialize(url:, api_version: 'v1', debug: false) @url = url @api_version = api_version @debug = debug @allowed_methods_hash = Phantasma::API.allowed_methods_hash end |
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 |
# File 'lib/phantasma/API/request.rb', line 24 def method_missing(method_name, *args, &block) return super(method_name, *args, &block) unless @allowed_methods_hash.include?(method_name.to_s) self.class.send(:define_method, method_name) do |*method_args| build_request(method_name, method_args) end self.send(method_name, *args, &block) end |
Instance Attribute Details
#api_version ⇒ Object
Returns the value of attribute api_version.
11 12 13 |
# File 'lib/phantasma/API/request.rb', line 11 def api_version @api_version end |
#debug ⇒ Object
Returns the value of attribute debug.
11 12 13 |
# File 'lib/phantasma/API/request.rb', line 11 def debug @debug end |
#url ⇒ Object
Returns the value of attribute url.
11 12 13 |
# File 'lib/phantasma/API/request.rb', line 11 def url @url end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
20 21 22 |
# File 'lib/phantasma/API/request.rb', line 20 def respond_to_missing?(method_name, include_private = false) @allowed_methods_hash.include?(method_name.to_s) || super end |