Module: JSONResponse
Defined Under Namespace
Classes: JSONStruct
Constant Summary collapse
- VERSION =
"0.0.3"
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
38 39 40 |
# File 'lib/json_response.rb', line 38 def attributes_for(name, ={}) registry[name].build.merge() end |
#build(name, options = {}) ⇒ Object
34 35 36 |
# File 'lib/json_response.rb', line 34 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
30 31 32 |
# File 'lib/json_response.rb', line 30 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 |