Class: Ace::Search::Models::SearchPreset
- Inherits:
-
Object
- Object
- Ace::Search::Models::SearchPreset
- Defined in:
- lib/ace/search/models/search_preset.rb
Overview
SearchPreset represents a named search configuration This is a model - pure data structure
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, description: nil, **options) ⇒ SearchPreset
constructor
A new instance of SearchPreset.
- #to_h ⇒ Object
Constructor Details
#initialize(name, description: nil, **options) ⇒ SearchPreset
Returns a new instance of SearchPreset.
11 12 13 14 15 |
# File 'lib/ace/search/models/search_preset.rb', line 11 def initialize(name, description: nil, **) @name = name @description = description @options = end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
9 10 11 |
# File 'lib/ace/search/models/search_preset.rb', line 9 def description @description end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/ace/search/models/search_preset.rb', line 9 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/ace/search/models/search_preset.rb', line 9 def @options end |
Class Method Details
.from_hash(data) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/ace/search/models/search_preset.rb', line 24 def self.from_hash(data) name = data[:name] || data["name"] description = data[:description] || data["description"] = data.reject { |k, _v| [:name, :description, "name", "description"].include?(k) } new(name, description: description, **) end |
Instance Method Details
#to_h ⇒ Object
17 18 19 20 21 22 |
# File 'lib/ace/search/models/search_preset.rb', line 17 def to_h { name: @name, description: @description }.merge(@options) end |