Class: BankLink::Link
- Inherits:
-
Object
- Object
- BankLink::Link
- Defined in:
- lib/bank_link/link.rb
Instance Attribute Summary collapse
-
#bank ⇒ Object
Returns the value of attribute bank.
-
#form ⇒ Object
Returns the value of attribute form.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #apply_encoding(content) ⇒ Object
- #calculate_keys(content, object) ⇒ Object
- #calculate_mac(content) ⇒ Object
-
#initialize(bank, url) {|form| ... } ⇒ Link
constructor
A new instance of Link.
- #processed_data(object, overrides = {}) ⇒ Object
- #settings(*args, &block) ⇒ Object
Constructor Details
#initialize(bank, url) {|form| ... } ⇒ Link
Returns a new instance of Link.
5 6 7 8 9 10 |
# File 'lib/bank_link/link.rb', line 5 def initialize bank, url, &block self.bank = bank self.url = url self.form = Hashie::Mash.new yield(form) if block_given? end |
Instance Attribute Details
#bank ⇒ Object
Returns the value of attribute bank.
3 4 5 |
# File 'lib/bank_link/link.rb', line 3 def bank @bank end |
#form ⇒ Object
Returns the value of attribute form.
3 4 5 |
# File 'lib/bank_link/link.rb', line 3 def form @form end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/bank_link/link.rb', line 3 def url @url end |
Instance Method Details
#apply_encoding(content) ⇒ Object
30 31 32 |
# File 'lib/bank_link/link.rb', line 30 def apply_encoding content content[settings.encoding_key] = settings.encoding if settings.encoding && settings.encoding_key end |
#calculate_keys(content, object) ⇒ Object
24 25 26 27 28 |
# File 'lib/bank_link/link.rb', line 24 def calculate_keys content, object content.each do |key, value| content[key] = content[key].call(self, object) if content[key].is_a?(Proc) end end |
#calculate_mac(content) ⇒ Object
34 35 36 37 |
# File 'lib/bank_link/link.rb', line 34 def calculate_mac content mac = settings.mac_class.new(self, content) content[mac.key] = mac.generate end |
#processed_data(object, overrides = {}) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/bank_link/link.rb', line 16 def processed_data object, overrides={} content = Hashie::Mash.new(form.merge(overrides)) apply_encoding content calculate_keys content, object calculate_mac content content end |
#settings(*args, &block) ⇒ Object
12 13 14 |
# File 'lib/bank_link/link.rb', line 12 def settings *args, &block bank.settings *args, &block end |