Class: Bbq::Widget::WithinCssId

Inherits:
Object
  • Object
show all
Defined in:
lib/bbq-widget/within_css_id.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, css_id) ⇒ WithinCssId

parent must respond to capybara dsl. It does not matter if it is user or widget



14
15
16
17
18
# File 'lib/bbq-widget/within_css_id.rb', line 14

def initialize(parent, css_id)
  @parent = parent
  self.css_id = "##{css_id}"
  return self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *arguments, &block) ⇒ Object



35
36
37
38
39
# File 'lib/bbq-widget/within_css_id.rb', line 35

def method_missing(method_id, *arguments, &block)
  withinme do
    @parent.send(method_id, *arguments, &block)
  end
end

Instance Attribute Details

#css_idObject

Returns the value of attribute css_id.



9
10
11
# File 'lib/bbq-widget/within_css_id.rb', line 9

def css_id
  @css_id
end

Instance Method Details

#has!(*params) ⇒ Object



55
56
57
# File 'lib/bbq-widget/within_css_id.rb', line 55

def has!(*params)
  see!(*params)
end

#has?(*params) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/bbq-widget/within_css_id.rb', line 51

def has?(*params)
  see?(*params)
end

#lacks!(*params) ⇒ Object



63
64
65
# File 'lib/bbq-widget/within_css_id.rb', line 63

def lacks!(*params)
  not_see!(*params)
end

#lacks?(*params) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/bbq-widget/within_css_id.rb', line 59

def lacks?(*params)
  not_see?(*params)
end

#respond_to?(method_id, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/bbq-widget/within_css_id.rb', line 42

def respond_to?(method_id, include_private = false)
  @parent.respond_to?(method_id) || super
end

#respond_to_missing?(method_id, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/bbq-widget/within_css_id.rb', line 46

def respond_to_missing?(method_id, include_private = false)
  @parent.respond_to?(method_id) || super
end

#withinmeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bbq-widget/within_css_id.rb', line 20

def withinme
  if @withinme
    yield
  else
    begin
      @withinme = true
      @parent.within(:css, css_id) do
        yield
      end
    ensure
      @withinme = false
    end
  end
end