Class: Resources::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/resources/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

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
  options = args.extract_options!
  self.rest_actions = options[:rest_actions] || true
  self.search = options[:search] || false
  self.flash = options[:flash] || false
  self.search_options = options[:search_options] && options[:search_options].is_a?(Hash) ? options[:search_options] : {distinct: false}
  self.params_search = options[:params_search] || :q
  self.params_resource = options[:params_resource] || :resource
  self.params_page = options[:params_page] || :page
  self.pagination = options[:pagination] || false
  self.resource_scope = options[:resource_scope] || nil
  self.resources_scope = options[:resources_scope] || nil
  self.resource_method_name = options[:resource_method_name] || :resource
  self.resources_method_name = options[:resources_method_name] || :resources
  if self.resource_method_name.to_s != "resource" && options[:resources_method_name].to_s == "resources"
    self.resources_method_name = self.resource_method_name.to_s.pluralize
  end
end

Class Method Details

.accessorsObject



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_hashObject



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