Class: Capybara::Harness::Dom::Attribute

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/harness/dom/attribute.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Attribute

Returns a new instance of Attribute.



6
7
8
9
# File 'lib/capybara/harness/dom/attribute.rb', line 6

def initialize(name, options = {})
  self.name = name
  self.derived_value_block = options.delete(:derived_value_block)
end

Instance Attribute Details

#derived_value_blockObject

Returns the value of attribute derived_value_block.



4
5
6
# File 'lib/capybara/harness/dom/attribute.rb', line 4

def derived_value_block
  @derived_value_block
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/capybara/harness/dom/attribute.rb', line 4

def name
  @name
end

Instance Method Details

#derive_value(values = {}) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/capybara/harness/dom/attribute.rb', line 11

def derive_value(values = {})
  if derived_value_block
    derived_value_block.call(values)
  else
    values.fetch(name, "")
  end
end