class Trailblazer::Finder::Utils::Splitter

Attributes

key[R]
value[R]

Public Class Methods

new(key, value) click to toggle source
# File lib/trailblazer/finder/utils/splitter.rb, line 10
def initialize(key, value)
  @key = key
  @value = value.to_s
end

Public Instance Methods

===(suffix)
Alias for: split_key
=~(suffix)
Alias for: split_key
field() click to toggle source

return name if the split was successful, or fall back to key which is handy when none of the predicates match and so key is probably just a field name.

# File lib/trailblazer/finder/utils/splitter.rb, line 30
def field
  (@field || @key)
end
predicate() click to toggle source

the predicate

# File lib/trailblazer/finder/utils/splitter.rb, line 35
def predicate
  @predicate.to_sym
end
split_key(suffix) click to toggle source

split suffix from the key and store the two values as name and op return truthy if successful

# File lib/trailblazer/finder/utils/splitter.rb, line 17
def split_key(suffix)
  rv = @key =~ /\A(?:(.*?)_)?(#{suffix})\z/
  @field = Regexp.last_match(1)
  @predicate = Regexp.last_match(2)
  !rv.nil?
end
Also aliased as: ===, =~