Class: Resources::Configuration
- Inherits:
-
Object
- Object
- Resources::Configuration
- Defined in:
- lib/resources/configuration.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Configuration
constructor
A new instance of Configuration.
- #to_hash ⇒ Object
Constructor Details
#initialize(*args) ⇒ Configuration
Returns a new instance of Configuration.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/resources/configuration.rb', line 9 def initialize *args = args. self.rest_actions = [:rest_actions] || true self.search = [:search] || false self.flash = [:flash] || false self. = [:search_options] && [:search_options].is_a?(Hash) ? [:search_options] : {distinct: false} self.params_search = [:params_search] || :q self.params_resource = [:params_resource] || :resource self.params_page = [:params_page] || :page self.pagination = [:pagination] || false self.resource_scope = [:resource_scope] || nil self.resources_scope = [:resources_scope] || nil self.resource_method_name = [:resource_method_name] || :resource self.resources_method_name = [:resources_method_name] || :resources if self.resource_method_name.to_s != "resource" && [:resources_method_name].to_s == "resources" self.resources_method_name = self.resource_method_name.to_s.pluralize end end |
Class Method Details
.accessors ⇒ Object
4 5 6 |
# File 'lib/resources/configuration.rb', line 4 def self.accessors [:rest_actions, :search, :search_options, :params_search, :resource_class_name, :resource_scope, :resources_scope, :resource_method_name, :resources_method_name, :params_resource, :pagination, :params_page, :flash] end |
Instance Method Details
#to_hash ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/resources/configuration.rb', line 29 def to_hash hash =HashWithIndifferentAccess.new self.class.accessors.each do |m| hash[m] = send(m) end hash end |