Class: Sigiss::Gateway

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, ActiveModel::Validations::Callbacks
Defined in:
lib/sigiss/gateway.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, environment = :test) ⇒ Gateway

Returns a new instance of Gateway.



15
16
17
18
19
# File 'lib/sigiss/gateway.rb', line 15

def initialize(name = nil, environment = :test)
  @name = name
  @url = url_webservice(name, environment)
  @environment = environment
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



8
9
10
# File 'lib/sigiss/gateway.rb', line 8

def environment
  @environment
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/sigiss/gateway.rb', line 9

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/sigiss/gateway.rb', line 9

def url
  @url
end

Instance Method Details

#url_webservice(name, environment) ⇒ Object



21
22
23
# File 'lib/sigiss/gateway.rb', line 21

def url_webservice(name, environment)
  YAML.load_file(File.join(Sigiss.root, 'configs.yml'))[environment.to_s][name.to_s]
end

#validate_if_gateway_existsObject



25
26
27
# File 'lib/sigiss/gateway.rb', line 25

def validate_if_gateway_exists
  errors.add(:name, :invalid) if @url.nil?
end