Class: Ddr::RightsStatement

Inherits:
Struct
  • Object
show all
Defined in:
app/models/ddr/rights_statement.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#featureObject

Returns the value of attribute feature

Returns:

  • (Object)

    the current value of feature



2
3
4
# File 'app/models/ddr/rights_statement.rb', line 2

def feature
  @feature
end

#reuse_textObject

Returns the value of attribute reuse_text

Returns:

  • (Object)

    the current value of reuse_text



2
3
4
# File 'app/models/ddr/rights_statement.rb', line 2

def reuse_text
  @reuse_text
end

#short_titleObject

Returns the value of attribute short_title

Returns:

  • (Object)

    the current value of short_title



2
3
4
# File 'app/models/ddr/rights_statement.rb', line 2

def short_title
  @short_title
end

#titleObject

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



2
3
4
# File 'app/models/ddr/rights_statement.rb', line 2

def title
  @title
end

#urlObject

Returns the value of attribute url

Returns:

  • (Object)

    the current value of url



2
3
4
# File 'app/models/ddr/rights_statement.rb', line 2

def url
  @url
end

Class Method Details

.allObject



12
13
14
# File 'app/models/ddr/rights_statement.rb', line 12

def self.all
  keystore.values
end

.call(obj) ⇒ Object



16
17
18
19
20
21
22
23
# File 'app/models/ddr/rights_statement.rb', line 16

def self.call(obj)
  return if obj.rights.empty?

  keystore.fetch(obj.rights.first)

rescue KeyError => _
  raise Ddr::NotFoundError, "Rights statement '#{obj.rights.first}' not found."
end

.configObject



4
5
6
# File 'app/models/ddr/rights_statement.rb', line 4

def self.config
  @config ||= YAML.load_file(::File.expand_path('../../../config/aux/rights_statement.yml', __dir__))
end

.keysObject



25
26
27
# File 'app/models/ddr/rights_statement.rb', line 25

def self.keys
  keystore.keys
end

.keystoreObject



8
9
10
# File 'app/models/ddr/rights_statement.rb', line 8

def self.keystore
  @keystore ||= Hash[config.map { |entry| [entry['url'], new(entry).freeze] }].freeze
end

Instance Method Details

#to_sObject



29
30
31
# File 'app/models/ddr/rights_statement.rb', line 29

def to_s
  title
end