Class: Minecraft::JSONAPIv2::Namespace
- Inherits:
-
Object
- Object
- Minecraft::JSONAPIv2::Namespace
- Defined in:
- lib/minecraft_jsonapiv2/namespace.rb
Instance Method Summary collapse
- #call(method) ⇒ Object
-
#initialize(parent, namespace, options = {}) ⇒ Namespace
constructor
A new instance of Namespace.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(parent, namespace, options = {}) ⇒ Namespace
Returns a new instance of Namespace.
4 5 6 7 |
# File 'lib/minecraft_jsonapiv2/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_jsonapiv2/namespace.rb', line 9 def method_missing(method, *args) method = [@namespace.gsub(/_/,'.'), method.to_s].join('.') opts = {name: method, args: args} @parent.call(opts) end |
Instance Method Details
#call(method) ⇒ Object
16 17 18 |
# File 'lib/minecraft_jsonapiv2/namespace.rb', line 16 def call(method) @parent.call(methodd) end |