lib/ezid/identifier.rb in ezid-client-1.2.0 vs lib/ezid/identifier.rb in ezid-client-1.3.0

- old
+ new

@@ -12,15 +12,10 @@ private :state, :state=, :id= # Attributes to display on inspect INSPECT_ATTRS = %w( id status target created ).freeze - # EZID status terms - PUBLIC = "public".freeze - RESERVED = "reserved".freeze - UNAVAILABLE = "unavailable".freeze - class << self attr_accessor :defaults # Creates or mints an identifier (depending on arguments) # @see #save @@ -149,23 +144,23 @@ end # Is the identifier reserved? # @return [Boolean] def reserved? - status == RESERVED + status == Status::RESERVED end # Is the identifier public? # @return [Boolean] def public? - status == PUBLIC + status == Status::PUBLIC end # Is the identifier unavailable? # @return [Boolean] def unavailable? - status =~ /^#{UNAVAILABLE}/ + status.to_s.start_with? Status::UNAVAILABLE end # Is the identifier deletable? # @return [Boolean] def deletable? @@ -180,20 +175,20 @@ raise Error, "Cannot make a reserved identifier unavailable." end if unavailable? and reason.nil? return end - value = UNAVAILABLE + value = Status::UNAVAILABLE if reason value += " | #{reason}" end self.status = value end # Mark the identifier as public # @return [String] the new status def public! - self.status = PUBLIC + self.status = Status::PUBLIC end protected def method_missing(method, *args)