Class: AsJson::ScopedJsonMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/as_json/scoped_json_mapper.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ ScopedJsonMapper

Returns a new instance of ScopedJsonMapper.



5
6
7
# File 'lib/as_json/scoped_json_mapper.rb', line 5

def initialize(klass)
  @klass = klass
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, **kargs) ⇒ Object



9
10
11
# File 'lib/as_json/scoped_json_mapper.rb', line 9

def method_missing(name, *args, **kargs)
  @klass.json_with "with_#{name}": kargs.merge(args.map { |key| [key, true] }.to_h)
end

Instance Method Details

#respond_to_missing?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/as_json/scoped_json_mapper.rb', line 13

def respond_to_missing?
  true
end