Class: ActiveAdmin::SearchableSelect::OptionCollection Private
- Inherits:
-
Object
- Object
- ActiveAdmin::SearchableSelect::OptionCollection
- Defined in:
- lib/activeadmin/searchable_select/option_collection.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #as_json(template, params) ⇒ Object private
- #collection_action_name ⇒ Object private
- #display_text(record) ⇒ Object private
-
#initialize(name, options) ⇒ OptionCollection
constructor
private
A new instance of OptionCollection.
- #scope(template, params) ⇒ Object private
Constructor Details
#initialize(name, options) ⇒ OptionCollection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of OptionCollection.
5 6 7 8 9 10 11 12 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 5 def initialize(name, ) @name = name @scope = extract_scope_option() @display_text = extract_display_text_option() @filter = extract_filter_option() @per_page = .fetch(:per_page, 10) @additional_payload = .fetch(:additional_payload, {}) end |
Instance Method Details
#as_json(template, params) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 35 def as_json(template, params) records, more = fetch_records(template, params) results = records.map do |record| { id: record.id, text: display_text(record) }.merge(hash_of_additional_payload(record) || {}) end { results: results, pagination: { more: more } } end |
#collection_action_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 31 def collection_action_name "#{@name}_options" end |
#display_text(record) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 27 def display_text(record) @display_text.call(record) end |
#scope(template, params) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 14 def scope(template, params) case @scope when Proc if @scope.arity.zero? template.instance_exec(&@scope) else template.instance_exec(params, &@scope) end else @scope end end |