Module: JSONResponse
Defined Under Namespace
Classes: JSONStruct
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
- #attributes_for(name, options = {}) ⇒ Object
- #build(name, options = {}) ⇒ Object
- #counters ⇒ Object
- #define(name, &block) ⇒ Object
- #next(name) ⇒ Object
Instance Method Details
#attributes_for(name, options = {}) ⇒ Object
39 40 41 |
# File 'lib/json_response.rb', line 39 def attributes_for(name, ={}) registry[name].build.merge() end |
#build(name, options = {}) ⇒ Object
35 36 37 |
# File 'lib/json_response.rb', line 35 def build(name, ={}) JSON.generate(registry[name].build.merge()) end |
#counters ⇒ Object
8 9 10 |
# File 'lib/json_response.rb', line 8 def counters @counters ||= Hash.new(0) end |
#define(name, &block) ⇒ Object
31 32 33 |
# File 'lib/json_response.rb', line 31 def define(name, &block) registry[name] = JSONStruct.new(&block) end |
#next(name) ⇒ Object
12 13 14 |
# File 'lib/json_response.rb', line 12 def next(name) counters[name] += 1 end |