Class: Hyrax::Identifier::Builder
- Inherits:
-
Object
- Object
- Hyrax::Identifier::Builder
- Defined in:
- app/services/hyrax/identifier/builder.rb
Overview
Builds an identifier string.
Implementations must accept a ‘prefix:` to `#initialize`, and a `hint:` to `#build`. Either or both may be used at the preference of the specific implementer or ignored entirely when `#build` is called.
Instance Attribute Summary collapse
-
#prefix ⇒ String
The prefix to use when building identifiers.
Instance Method Summary collapse
- #build(hint: nil) ⇒ String
-
#initialize(prefix: 'pfx') ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(prefix: 'pfx') ⇒ Builder
Returns a new instance of Builder.
22 23 24 |
# File 'app/services/hyrax/identifier/builder.rb', line 22 def initialize(prefix: 'pfx') @prefix = prefix end |
Instance Attribute Details
#prefix ⇒ String
Returns the prefix to use when building identifiers.
18 19 20 |
# File 'app/services/hyrax/identifier/builder.rb', line 18 def prefix @prefix end |
Instance Method Details
#build(hint: nil) ⇒ String
Note:
this default builder requires a ‘hint` which it appends to the prefix to generate the identifier string.
37 38 39 40 41 42 |
# File 'app/services/hyrax/identifier/builder.rb', line 37 def build(hint: nil) raise(ArgumentError, "No hint provided to #{self.class}#build") if hint.nil? "#{prefix}/#{hint}" end |