Module: RDBr::Web::SearchValueHelpers
- Included in:
- Helpers
- Defined in:
- lib/rdbr/web/search_value_helpers.rb
Constant Summary collapse
- BIT_TYPES =
%i[bit varbit].freeze
- SEARCH_TYPES =
%i[tsquery tsvector].freeze
Instance Method Summary collapse
- #deferred_bit_value?(column) ⇒ Boolean
- #deferred_search_value?(column) ⇒ Boolean
- #render_bit_value(value) ⇒ Object
- #render_search_value(column, value) ⇒ Object
Instance Method Details
#deferred_bit_value?(column) ⇒ Boolean
7 8 9 10 |
# File 'lib/rdbr/web/search_value_helpers.rb', line 7 def deferred_bit_value?(column) type = column.logical_type.to_s.to_sym (BIT_TYPES.include?(type) || column.sql_type.to_s.match?(/\bbit(?: varying)?\b/i)) && !vector_column?(column) end |
#deferred_search_value?(column) ⇒ Boolean
12 13 14 15 |
# File 'lib/rdbr/web/search_value_helpers.rb', line 12 def deferred_search_value?(column) type = column.logical_type.to_s.to_sym SEARCH_TYPES.include?(type) || column.sql_type.to_s.match?(/\b(?:tsquery|tsvector)\b/i) end |
#render_bit_value(value) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/rdbr/web/search_value_helpers.rb', line 17 def render_bit_value(value) text = value.to_s length = bit_content(text).length unit = length == 1 ? 'bit' : 'bits' render_deferred_value(text, qualifier: 'bit-string', summary: "#{length} #{unit}") end |
#render_search_value(column, value) ⇒ Object
24 25 26 27 28 |
# File 'lib/rdbr/web/search_value_helpers.rb', line 24 def render_search_value(column, value) type = search_type(column) summary = type == :tsvector ? tsvector_summary(value) : tsquery_summary(value) render_deferred_value(value, qualifier: 'full-text', summary: summary) end |