Module: ActsAsExplorable::Explorable
- Defined in:
- lib/acts_as_explorable/explorable.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#explorable(filters = {}) {|config| ... } ⇒ Object
Configure ActsAsExplorable’s behavior in a model.
Class Method Details
.extended(base) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/acts_as_explorable/explorable.rb', line 3 def self.extended(base) base.class_eval do def self.explorable? false end end end |
Instance Method Details
#explorable(filters = {}) {|config| ... } ⇒ Object
Configure ActsAsExplorable’s behavior in a model.
The plugin can be customized using parameters or through a block.
class Player < ActiveRecord::Base
extend ActsAsExplorable
explorable in: [:first_name, :last_name, :position, :city, :club],
sort: [:first_name, :last_name, :position, :city, :club, :created_at],
position: ['GK', 'MF', 'FW']
end
Using a block (TODO: This will be available in future versions):
class Player < ActiveRecord::Base
extend ActsAsExplorable
explorable do |config|
config.filters = {
in: [:first_name, :last_name, :position, :city, :club],
sort: [:first_name, :last_name, :position, :city, :club, :created_at],
position: ['GK', 'MF', 'FW']
}
end
end
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/acts_as_explorable/explorable.rb', line 39 def explorable(filters = {}, &_block) class_eval do def self.explorable? true end end if block_given? ActsAsExplorable.setup { |config| yield config } else explorable_set_filters filters end end |