Class: Hydra::AccessControls::Permission
- Inherits:
-
AccessControlList
- Object
- ActiveFedora::Base
- AccessControlList
- Hydra::AccessControls::Permission
- Defined in:
- app/models/hydra/access_controls/permission.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #access ⇒ Object
- #agent_name ⇒ Object
- #assign_attributes(attributes) ⇒ Object
-
#initialize(args) ⇒ Permission
constructor
A new instance of Permission.
- #inspect ⇒ Object
- #to_hash ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(args) ⇒ Permission
Returns a new instance of Permission.
8 9 10 11 12 |
# File 'app/models/hydra/access_controls/permission.rb', line 8 def initialize(args) super() build_agent(args[:name], args[:type].to_s) build_access(args[:access]) end |
Instance Method Details
#==(other) ⇒ Object
24 25 26 27 |
# File 'app/models/hydra/access_controls/permission.rb', line 24 def ==(other) other.is_a?(Permission) && id == other.id && access_to_id == other.access_to_id && agent.first.rdf_subject == other.agent.first.rdf_subject && mode.first.rdf_subject == other.mode.first.rdf_subject end |
#access ⇒ Object
43 44 45 |
# File 'app/models/hydra/access_controls/permission.rb', line 43 def access @access ||= mode.first.rdf_subject.to_s.split('#').last.downcase.sub('write', 'edit') end |
#agent_name ⇒ Object
39 40 41 |
# File 'app/models/hydra/access_controls/permission.rb', line 39 def agent_name parsed_agent.last end |
#assign_attributes(attributes) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/models/hydra/access_controls/permission.rb', line 29 def assign_attributes(attributes) attrs = attributes.dup name = attrs.delete(:name) type = attrs.delete(:type) build_agent(name, type) if name && type access = attrs.delete(:access) build_access(access) if access super(attrs) end |
#inspect ⇒ Object
18 19 20 21 22 |
# File 'app/models/hydra/access_controls/permission.rb', line 18 def inspect agent_value = agent.first.rdf_subject.to_s.inspect if agent.first mode_value = mode.first.rdf_subject.to_s.inspect if mode.first "<#{self.class.name} id: #{id} agent: #{agent_value} mode: #{mode_value} access_to: #{access_to_id.inspect}>" end |
#to_hash ⇒ Object
14 15 16 |
# File 'app/models/hydra/access_controls/permission.rb', line 14 def to_hash { name: agent_name, type: type, access: access } end |
#type ⇒ Object
47 48 49 |
# File 'app/models/hydra/access_controls/permission.rb', line 47 def type parsed_agent.first end |