Class: Minecraft::JSONAPI::Namespace
- Inherits:
-
Object
- Object
- Minecraft::JSONAPI::Namespace
- Defined in:
- lib/minecraft-jsonapi/namespace.rb
Instance Method Summary collapse
-
#initialize(parent, namespace) ⇒ Namespace
constructor
A new instance of Namespace.
-
#make_url(*args) ⇒ Object
This will bubble upwards until we hit the actual JSONAPI class.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(parent, namespace) ⇒ Namespace
Returns a new instance of Namespace.
4 5 6 7 |
# File 'lib/minecraft-jsonapi/namespace.rb', line 4 def initialize(parent, namespace) @parent = parent @namespace = namespace end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/minecraft-jsonapi/namespace.rb', line 9 def method_missing(method, *args) method = [@namespace, method.to_s].join(".") url = @parent.make_url(method, args) Minecraft::JSONAPI.send_request(url) end |
Instance Method Details
#make_url(*args) ⇒ Object
This will bubble upwards until we hit the actual JSONAPI class
17 18 19 |
# File 'lib/minecraft-jsonapi/namespace.rb', line 17 def make_url(*args) @parent.make_url(*args) end |