Class: Chemlab::Component
- Inherits:
-
Object
- Object
- Chemlab::Component
- Extended by:
- SingleForwardable
- Defined in:
- lib/chemlab/component.rb
Overview
The base representation of any UI component.
Direct Known Subclasses
Defined Under Namespace
Classes: DSL
Class Method Summary collapse
-
.perform {|new| ... } ⇒ Object
Perform actions against the given page.
-
.public_elements ⇒ Array
Elements defined on the page.
Instance Method Summary collapse
-
#visible? ⇒ Boolean
If this component is currently visible.
Class Method Details
.perform {|new| ... } ⇒ Object
Perform actions against the given page
21 22 23 |
# File 'lib/chemlab/component.rb', line 21 def self.perform yield new if block_given? end |
.public_elements ⇒ Array
Elements defined on the page
36 37 38 |
# File 'lib/chemlab/component.rb', line 36 def public_elements @public_elements ||= [] end |
Instance Method Details
#visible? ⇒ Boolean
Note:
The page presence is determined by the elements defined on the page and their requirement
If this component is currently visible
88 89 90 91 92 93 94 95 96 |
# File 'lib/chemlab/component.rb', line 88 def visible? missing_elements = [] + self.class.public_elements self.class.public_elements.each do |element| missing_elements.shift if has_element?(element[:type], element[:name], element[:args].first) end missing_elements.none? end |