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.
7 8 9 |
# File 'lib/gateway_signup/engines/yaml.rb', line 7 def initialize(file) @gw_data = YAML.load_file file end |
Instance Method Details
#countries ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gateway_signup/engines/yaml.rb', line 20 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
42 43 44 |
# File 'lib/gateway_signup/engines/yaml.rb', line 42 def details(gateway) @gw_data[gateway.to_sym] end |
#fields_for(gateway) ⇒ Object
11 12 13 14 |
# File 'lib/gateway_signup/engines/yaml.rb', line 11 def fields_for(gateway) @list = @gw_data[gateway.to_sym][:fields] @list end |
#for_country(country) ⇒ Object
46 47 48 |
# File 'lib/gateway_signup/engines/yaml.rb', line 46 def for_country(country) gateways.select { |gw| @gw_data[gw][:countries].include? country } end |
#gateway_list ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/gateway_signup/engines/yaml.rb', line 32 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
16 17 18 |
# File 'lib/gateway_signup/engines/yaml.rb', line 16 def gateways @gw_data.keys end |
#hash_tree ⇒ Object
50 51 52 53 54 |
# File 'lib/gateway_signup/engines/yaml.rb', line 50 def hash_tree Hash.new do |hash, key| hash[key] = hash_tree end end |