Class: Commands::SearchResult
- Inherits:
-
Object
- Object
- Commands::SearchResult
- Defined in:
- app/models/kommandant/commands/search_result.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #http_method ⇒ Object
-
#initialize(command:, resource:) ⇒ SearchResult
constructor
A new instance of SearchResult.
- #name ⇒ Object
- #path ⇒ Object
Constructor Details
#initialize(command:, resource:) ⇒ SearchResult
Returns a new instance of SearchResult.
3 4 5 6 |
# File 'app/models/kommandant/commands/search_result.rb', line 3 def initialize(command:, resource:) @command = command @resource = resource end |
Instance Attribute Details
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
8 9 10 |
# File 'app/models/kommandant/commands/search_result.rb', line 8 def resource @resource end |
Instance Method Details
#http_method ⇒ Object
25 26 27 |
# File 'app/models/kommandant/commands/search_result.rb', line 25 def http_method :get end |
#name ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/models/kommandant/commands/search_result.rb', line 11 def name if command.translator.exists?(I18n.locale, "result_text") command.translator.translate(I18n.locale, "result_text") else indexed_attribute_for(resource, command.search_result_text_method) end end |
#path ⇒ Object
19 20 21 22 23 |
# File 'app/models/kommandant/commands/search_result.rb', line 19 def path return command.redirect_path.gsub(":id", resource.id.to_s) if command.redirect_path "/#{command.resource_class.downcase.pluralize}/#{resource.id}" end |