immutable_drop: use custom error for bad set

This commit is contained in:
Parker Moore 2015-12-24 15:06:32 -05:00
parent 6a72d4a986
commit bff1726a5a
2 changed files with 3 additions and 1 deletions

View File

@ -32,6 +32,7 @@ require 'colorator'
SafeYAML::OPTIONS[:suppress_warnings] = true
module Jekyll
StandardError = Class.new(::StandardError)
# internal requires
autoload :Cleaner, 'jekyll/cleaner'

View File

@ -3,6 +3,7 @@
module Jekyll
module Drops
class ImmutableDrop < Liquid::Drop
IllegalDropModification = Class.new(Jekyll::StandardError)
def initialize(obj)
@obj = obj
@ -18,7 +19,7 @@ module Jekyll
def []=(key, val)
if respond_to? key
raise ArgumentError.new("Key #{key} cannot be set in the drop.")
raise IllegalDropModification.new("Key #{key} cannot be set in the drop.")
else
fallback_data[key] = val
end