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 |
# 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) 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.
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 34 def as_json(template, params) records, more = fetch_records(template, params) results = records.map do |record| { id: record.id, text: display_text(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.
30 31 32 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 30 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.
26 27 28 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 26 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.
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/activeadmin/searchable_select/option_collection.rb', line 13 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 |