Class: Platform::Matcher
- Inherits:
-
Object
- Object
- Platform::Matcher
- Defined in:
- lib/hanami/devtools/integration/platform/matcher.rb
Overview
Match current platform variables like Ruby engine, current database.
Defined Under Namespace
Classes: Nope
Class Method Summary collapse
Instance Method Summary collapse
- #default(&blk) ⇒ Object
- #engine(name, &blk) ⇒ Object
-
#initialize ⇒ Matcher
constructor
A new instance of Matcher.
- #os(name, &blk) ⇒ Object
Constructor Details
#initialize ⇒ Matcher
Returns a new instance of Matcher.
35 36 37 |
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 35 def initialize freeze end |
Class Method Details
.match(&blk) ⇒ Object
23 24 25 26 27 |
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 23 def self.match(&blk) catch :match do new.__send__(:match, &blk) end end |
.match?(os: Os.current, engine: Engine.current) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 29 def self.match?(os: Os.current, engine: Engine.current) catch :match do new.os(os).engine(engine) { true }.or(false) end end |
Instance Method Details
#default(&blk) ⇒ Object
49 50 51 |
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 49 def default(&blk) resolve(&blk) end |
#engine(name, &blk) ⇒ Object
44 45 46 47 |
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 44 def engine(name, &blk) return nope unless engine?(name) block_given? ? resolve(&blk) : yep end |
#os(name, &blk) ⇒ Object
39 40 41 42 |
# File 'lib/hanami/devtools/integration/platform/matcher.rb', line 39 def os(name, &blk) return nope unless os?(name) block_given? ? resolve(&blk) : yep end |