Class: Yuriita::Table
- Inherits:
-
Object
- Object
- Yuriita::Table
- Includes:
- ActiveModel::Model
- Defined in:
- lib/yuriita/table.rb
Constant Summary collapse
- SPACE =
" ".freeze
- EMPTY_STRING =
"".freeze
Instance Attribute Summary collapse
-
#search ⇒ Object
readonly
Returns the value of attribute search.
Instance Method Summary collapse
- #default_input ⇒ Object
- #filtered? ⇒ Boolean
-
#initialize(relation:, params:, configuration:, param_key: :q) ⇒ Table
constructor
A new instance of Table.
- #items ⇒ Object
- #q ⇒ Object
Constructor Details
#initialize(relation:, params:, configuration:, param_key: :q) ⇒ Table
Returns a new instance of Table.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/yuriita/table.rb', line 12 def initialize( relation:, params:, configuration:, param_key: :q ) @relation = relation @params = params @configuration = configuration @param_key = param_key @search = Yuriita::Search.new(self, @param_key) end |
Instance Attribute Details
#search ⇒ Object (readonly)
Returns the value of attribute search.
25 26 27 |
# File 'lib/yuriita/table.rb', line 25 def search @search end |
Instance Method Details
#default_input ⇒ Object
50 51 52 |
# File 'lib/yuriita/table.rb', line 50 def default_input configuration.default_input end |
#filtered? ⇒ Boolean
46 47 48 |
# File 'lib/yuriita/table.rb', line 46 def filtered? user_input? && user_query != default_query end |
#items ⇒ Object
42 43 44 |
# File 'lib/yuriita/table.rb', line 42 def items Runner.new(relation: relation, configuration: configuration).run(query) end |
#q ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yuriita/table.rb', line 27 def q output = if user_input? user_input else default_input end if output.blank? EMPTY_STRING else output + SPACE end end |