Skip to content

Commit

Permalink
Freezes string constants
Browse files Browse the repository at this point in the history
Identifier#unavailable! patched to use += instead of << when adding reason
Fixes #45
  • Loading branch information
dchandekstark committed Apr 23, 2015
1 parent fbd7553 commit 9a218c9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/ezid/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ module Ezid
class Client

# ezid-client gem version (e.g., "0.8.0")
VERSION = File.read(File.expand_path("../../../VERSION", __FILE__)).chomp
VERSION = File.read(File.expand_path("../../../VERSION", __FILE__)).chomp.freeze

# EZID API version
API_VERSION = "2"
API_VERSION = "2".freeze

class << self
# Configuration reader
Expand Down
2 changes: 1 addition & 1 deletion lib/ezid/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Ezid
#
class Configuration

HOST = "ezid.cdlib.org"
HOST = "ezid.cdlib.org".freeze
PORT = 443
TIMEOUT = 300

Expand Down
12 changes: 7 additions & 5 deletions lib/ezid/identifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class Identifier
private :state, :state=, :id=

# Attributes to display on inspect
INSPECT_ATTRS = %w( id status target created )
INSPECT_ATTRS = %w( id status target created ).freeze

# EZID status terms
PUBLIC = "public"
RESERVED = "reserved"
UNAVAILABLE = "unavailable"
PUBLIC = "public".freeze
RESERVED = "reserved".freeze
UNAVAILABLE = "unavailable".freeze

class << self
attr_accessor :defaults
Expand Down Expand Up @@ -170,7 +170,9 @@ def deletable?
def unavailable!(reason = nil)
raise Error, "Cannot make a reserved identifier unavailable." if persisted? && reserved?
value = UNAVAILABLE
value << " | #{reason}" if reason
if reason
value += " | #{reason}"
end
self.status = value
end

Expand Down

0 comments on commit 9a218c9

Please sign in to comment.