Class: Hotdog::Commands::Search::TagRegexpExpressionNode
- Inherits:
-
TagExpressionNode
- Object
- ExpressionNode
- TagExpressionNode
- Hotdog::Commands::Search::TagRegexpExpressionNode
- Defined in:
- lib/hotdog/commands/search.rb
Instance Attribute Summary
Attributes inherited from TagExpressionNode
Instance Method Summary collapse
- #evaluate(environment) ⇒ Object
-
#initialize(identifier, attribute) ⇒ TagRegexpExpressionNode
constructor
A new instance of TagRegexpExpressionNode.
Methods inherited from TagExpressionNode
Constructor Details
#initialize(identifier, attribute) ⇒ TagRegexpExpressionNode
252 253 254 255 256 |
# File 'lib/hotdog/commands/search.rb', line 252 def initialize(identifier, attribute) identifier = identifier.sub(%r{\A/(.*)/\z}) { $1 } if identifier attribute = attribute.sub(%r{\A/(.*)/\z}) { $1 } if attribute super(identifier, attribute) end |
Instance Method Details
#evaluate(environment) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/hotdog/commands/search.rb', line 257 def evaluate(environment) if attribute? environment.execute(<<-EOS, identifier, attribute).map { |row| row.first } SELECT DISTINCT hosts_tags.host_id FROM hosts_tags INNER JOIN tags ON hosts_tags.tag_id = tags.id WHERE LOWER(tags.name) REGEXP LOWER(?) AND LOWER(tags.value) REGEXP LOWER(?); EOS else environment.execute(<<-EOS, identifier, identifier, identifier).map { |row| row.first } SELECT DISTINCT hosts_tags.host_id FROM hosts_tags INNER JOIN hosts ON hosts_tags.host_id = hosts.id INNER JOIN tags ON hosts_tags.tag_id = tags.id WHERE LOWER(hosts.name) REGEXP LOWER(?) OR LOWER(tags.name) REGEXP LOWER(?) OR LOWER(tags.value) REGEXP LOWER(?); EOS end end |