Class: Hydra::Config
- Inherits:
-
Object
- Object
- Hydra::Config
- Defined in:
- lib/hydra/config.rb
Defined Under Namespace
Classes: InheritablePermissionsConfig, PermissionsConfig
Instance Attribute Summary collapse
-
#id_to_resource_uri ⇒ Lambda
This is purely used for translating an ID to user-facing URIs not used for persistence.
-
#permissions ⇒ Object
Returns the value of attribute permissions.
- #user_key_field ⇒ Object
-
#user_model ⇒ Object
Returns the value of attribute user_model.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #default_user_key_field ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
3 4 5 6 |
# File 'lib/hydra/config.rb', line 3 def initialize @permissions = PermissionsConfig.new @user_model = 'User' end |
Instance Attribute Details
#id_to_resource_uri ⇒ Lambda
This is purely used for translating an ID to user-facing URIs not used for persistence. Useful for storing RDF in Fedora but displaying their subjects in content negotiation as local to the application.
52 53 54 |
# File 'lib/hydra/config.rb', line 52 def id_to_resource_uri @id_to_resource_uri ||= lambda { |id, _graph| ActiveFedora::Base.translate_id_to_uri.call(id) } end |
#permissions ⇒ Object
Returns the value of attribute permissions.
34 35 36 |
# File 'lib/hydra/config.rb', line 34 def @permissions end |
#user_key_field ⇒ Object
38 39 40 |
# File 'lib/hydra/config.rb', line 38 def user_key_field @user_key_field || default_user_key_field end |
#user_model ⇒ Object
Returns the value of attribute user_model.
36 37 38 |
# File 'lib/hydra/config.rb', line 36 def user_model @user_model end |
Instance Method Details
#[](key) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/hydra/config.rb', line 21 def [] key case key when :permissions when :user_model user_model when :id_to_resource_uri id_to_resource_uri else raise "Unknown key #{key}" end end |
#[]=(key, value) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/hydra/config.rb', line 8 def []= key, value case key when :permissions self. = value when :user_model self.user_model = value when :id_to_resource_uri self.id_to_resource_uri = value else raise "Unknown key" end end |
#default_user_key_field ⇒ Object
42 43 44 45 |
# File 'lib/hydra/config.rb', line 42 def default_user_key_field Deprecation.warn(self, "You must set 'config.user_key_field = Devise.authentication_keys.first' in your config/initializer/hydra_config.rb file. The default value will be removed in hydra-access-controls 12") Devise.authentication_keys.first end |