Class: GatewaySignup::Engines::Yaml
- Inherits:
-
Object
- Object
- GatewaySignup::Engines::Yaml
- Defined in:
- lib/gateway_signup/engines/yaml.rb
Instance Method Summary collapse
- #countries ⇒ Object
- #details(gateway) ⇒ Object
- #fields_for(gateway) ⇒ Object
- #for_country(country) ⇒ Object
- #gateway_list ⇒ Object
- #gateways ⇒ Object
- #hash_tree ⇒ Object
-
#initialize(file) ⇒ Yaml
constructor
A new instance of Yaml.
Constructor Details
#initialize(file) ⇒ Yaml
Returns a new instance of Yaml.
6 7 8 |
# File 'lib/gateway_signup/engines/yaml.rb', line 6 def initialize(file) @gw_data = YAML.load_file file end |
Instance Method Details
#countries ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gateway_signup/engines/yaml.rb', line 19 def countries @count=[] @gw_data.each do |k, v| @count = @count + v[:countries] end @count = @count.uniq.sort us = @count.index('US') @count.delete_at(us) @count = @count.unshift('US') @count.to_json.html_safe end |
#details(gateway) ⇒ Object
41 42 43 |
# File 'lib/gateway_signup/engines/yaml.rb', line 41 def details(gateway) @gw_data[gateway.to_sym] end |
#fields_for(gateway) ⇒ Object
10 11 12 13 |
# File 'lib/gateway_signup/engines/yaml.rb', line 10 def fields_for(gateway) @list = @gw_data[gateway.to_sym][:fields] @list end |
#for_country(country) ⇒ Object
45 46 47 |
# File 'lib/gateway_signup/engines/yaml.rb', line 45 def for_country(country) gateways.select { |gw| @gw_data[gw][:countries].include? country } end |
#gateway_list ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/gateway_signup/engines/yaml.rb', line 31 def gateway_list @list = hash_tree @gw_data.each do |k, v| @list[k]["display"] = v[:display_name] @list[k]["countries"] = v[:countries] @list[k]["notes"] = v[:notes] end @list.to_json.html_safe end |
#gateways ⇒ Object
15 16 17 |
# File 'lib/gateway_signup/engines/yaml.rb', line 15 def gateways @gw_data.keys end |
#hash_tree ⇒ Object
49 50 51 52 53 |
# File 'lib/gateway_signup/engines/yaml.rb', line 49 def hash_tree Hash.new do |hash, key| hash[key] = hash_tree end end |