lib/vedeu/repositories/repository.rb in vedeu-0.6.15 vs lib/vedeu/repositories/repository.rb in vedeu-0.6.16
- old
+ new
@@ -63,17 +63,13 @@
# @param name [String] The name of the stored model.
# @return [void]
def by_name(name)
name ||= Vedeu.focus
- if registered?(name)
- find(name)
+ return find(name) if registered?(name)
- else
- null_model.new(name: name)
-
- end
+ null_model.new(name: name)
end
# Return the model for the interface currently in focus.
#
# @return [String|NilClass]
@@ -105,20 +101,16 @@
# found.
#
# @param name [String]
# @return [void]
def find_or_create(name)
- if registered?(name)
- find(name)
+ return find(name) if registered?(name)
- else
- Vedeu.log(type: :store,
- message: "Model (#{model}) not found, " \
- "registering: '#{name}'")
+ Vedeu.log(type: :store,
+ message: "Model (#{model}) not found, registering: '#{name}'")
- model.new(name).store
- end
+ model.new(name).store
end
# @return [String]
def inspect
"<#{self.class.name}>"
@@ -141,18 +133,13 @@
#
# @param name [String]
# @return [Hash|FalseClass]
def remove(name)
return false if empty?
+ return false unless registered?(name)
- if registered?(name)
- storage.delete(name)
- storage unless storage.is_a?(Set)
-
- else
- false
-
- end
+ storage.delete(name)
+ storage unless storage.is_a?(Set)
end
alias_method :destroy, :remove
alias_method :delete, :remove
alias_method :deregister, :remove