Class: Appear::Revealers::BaseRevealer
- Inherits:
-
Service
- Object
- BaseService
- Service
- Appear::Revealers::BaseRevealer
- Defined in:
- lib/appear/revealers.rb
Overview
extend to implement more revealers
Direct Known Subclasses
Class Method Summary collapse
-
.register! ⇒ Object
Register this class as a revealer so it will be called by Instance#call.
Instance Method Summary collapse
-
#call(tree) ⇒ true?
Reveal ‘tree` if supported by this revealer.
-
#reveal_tree(tree) ⇒ true?
abstract
Reveal ‘tree`.
-
#supports_tree?(target, rest) ⇒ Boolean
abstract
Returns true if this revealer may be able to reveal something in the tree.
Methods inherited from BaseService
delegate, #initialize, require_service, required_services
Constructor Details
This class inherits a constructor from Appear::BaseService
Class Method Details
.register! ⇒ Object
Register this class as a revealer so it will be called by Instance#call
53 54 55 |
# File 'lib/appear/revealers.rb', line 53 def self.register! Appear::REVEALERS.push(self) end |
Instance Method Details
#call(tree) ⇒ true?
Reveal ‘tree` if supported by this revealer. You can get a tree from Processes#process_tree.
21 22 23 24 25 26 |
# File 'lib/appear/revealers.rb', line 21 def call(tree) target, *rest = tree if supports_tree?(target, rest) return reveal_tree(tree) end end |
#reveal_tree(tree) ⇒ true?
subclasses must implement this method.
Reveal ‘tree`. Should be implemented by subclasses.
33 34 35 |
# File 'lib/appear/revealers.rb', line 33 def reveal_tree(tree) raise "not implemented" end |
#supports_tree?(target, rest) ⇒ Boolean
subclasses must implement this method.
Returns true if this revealer may be able to reveal something in the tree. For this method, the caller splits the tree into the target and the rest of the tree, which sometimes simplifies the implementation of this method.
47 48 49 |
# File 'lib/appear/revealers.rb', line 47 def supports_tree?(target, rest) raise "not implemented" end |