Sha256: 37d2327479b9c08caa7dad0de0d9225ab53de1511331d8cdbffb4dfcbd0d1a2f
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 KB
Contents
module Resources class Configuration 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 accessors.map{|a| attr_accessor a } 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 def to_hash hash =HashWithIndifferentAccess.new self.class.accessors.each do |m| hash[m] = send(m) end hash end end Config = Resources::Configuration.new() def self.config(&block) yield(Config) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
resources-1.1.1 | lib/resources/configuration.rb |
resources-1.1.0 | lib/resources/configuration.rb |