Module: Subledger::Rest
- Defined in:
- lib/subledger/rest.rb
Class Method Summary collapse
- .present_collection(entity_name, collection) ⇒ Object
- .present_entity(entity) ⇒ Object
- .to_args(rest_args, client) ⇒ Object
- .to_balance(rest_args, client) ⇒ Object
Class Method Details
.present_collection(entity_name, collection) ⇒ Object
31 32 33 34 35 |
# File 'lib/subledger/rest.rb', line 31 def self.present_collection entity_name, collection entities = collection.collect { |entity| entity.serializable_hash } { entity_name => entities } end |
.present_entity(entity) ⇒ Object
27 28 29 |
# File 'lib/subledger/rest.rb', line 27 def self.present_entity entity { entity.entity_name => entity.serializable_hash } end |
.to_args(rest_args, client) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/subledger/rest.rb', line 3 def self.to_args rest_args, client args = { } rest_args.each do |key, value| key_symbol = key.to_sym unless value.nil? code = LAMBDAS[key] args[key_symbol] = if code.nil? or value.kind_of? Domain value else code.call client, args, key, value end end end args end |
.to_balance(rest_args, client) ⇒ Object
23 24 25 |
# File 'lib/subledger/rest.rb', line 23 def self.to_balance rest_args, client to_args( rest_args, client )[:balance] end |