Class: Rabarber::Configuration

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rabarber/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
# File 'lib/rabarber/configuration.rb', line 11

def initialize
  reset_to_defaults!
end

Instance Attribute Details

#cache_enabledObject

Returns the value of attribute cache_enabled.



9
10
11
# File 'lib/rabarber/configuration.rb', line 9

def cache_enabled
  @cache_enabled
end

#current_user_methodObject

Returns the value of attribute current_user_method.



9
10
11
# File 'lib/rabarber/configuration.rb', line 9

def current_user_method
  @current_user_method
end

#user_model_nameObject

Returns the value of attribute user_model_name.



9
10
11
# File 'lib/rabarber/configuration.rb', line 9

def user_model_name
  @user_model_name
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



53
54
55
# File 'lib/rabarber/configuration.rb', line 53

def configure
  yield self
end

#reset_to_defaults!Object



39
40
41
42
43
# File 'lib/rabarber/configuration.rb', line 39

def reset_to_defaults!
  self.cache_enabled = true
  self.current_user_method = :current_user
  self.user_model_name = "User"
end

#user_modelObject



45
46
47
48
49
50
51
# File 'lib/rabarber/configuration.rb', line 45

def user_model
  Rabarber::Inputs::Model.new(
    user_model_name,
    error: Rabarber::ConfigurationError,
    message: "Invalid configuration `user_model_name`, expected an ActiveRecord model name, got #{user_model_name.inspect}"
  ).process
end