summaryrefslogtreecommitdiff
path: root/lib/bundler/plugin
diff options
context:
space:
mode:
authorjules2689 <julian@jnadeau.ca>2018-05-25 08:26:13 -0400
committerjules2689 <julian@jnadeau.ca>2018-05-27 18:54:09 -0400
commitfdddb742067a3d8aee0b782d820305494d7b06c9 (patch)
tree8fdb3d8ece1759c9eb2ae866435df19c264d9229 /lib/bundler/plugin
parentae2237f6db2d690ddba43b692b9700ef64adda61 (diff)
downloadbundler-fdddb742067a3d8aee0b782d820305494d7b06c9.tar.gz
PR comments, some docs
Diffstat (limited to 'lib/bundler/plugin')
-rw-r--r--lib/bundler/plugin/events.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/bundler/plugin/events.rb b/lib/bundler/plugin/events.rb
index 3052780b1f..8e94644f2a 100644
--- a/lib/bundler/plugin/events.rb
+++ b/lib/bundler/plugin/events.rb
@@ -4,17 +4,27 @@ module Bundler
module Plugin
module Events
def self.define(const, event)
- const_set(const.to_sym, event) unless const_defined?(const.to_sym)
+ const = const.to_sym.freeze
+ if const_defined?(const) && const_get(const) != event
+ raise ArgumentError, "Attempting to reassign #{const} to a different value"
+ end
+ const_set(const, event) unless const_defined?(const)
@events ||= {}
@events[event] = const
end
+ private_class_method :define
+ # Check if an event has been defined
+ # @param event [String] An event to check
+ # @return [Boolean] A boolean indicating if the event has been defined
def self.defined_event?(event)
@events ||= {}
@events.key?(event)
end
- # A hook called before any gems install
+ # @!parse
+ # # A hook called before any gems install
+ # GEM_BEFORE_INSTALL_ALL = "before-install-all"
define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
end
end