immutable_drop: use custom error for bad set
This commit is contained in:
parent
6a72d4a986
commit
bff1726a5a
|
@ -32,6 +32,7 @@ require 'colorator'
|
||||||
SafeYAML::OPTIONS[:suppress_warnings] = true
|
SafeYAML::OPTIONS[:suppress_warnings] = true
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
StandardError = Class.new(::StandardError)
|
||||||
|
|
||||||
# internal requires
|
# internal requires
|
||||||
autoload :Cleaner, 'jekyll/cleaner'
|
autoload :Cleaner, 'jekyll/cleaner'
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
module Drops
|
module Drops
|
||||||
class ImmutableDrop < Liquid::Drop
|
class ImmutableDrop < Liquid::Drop
|
||||||
|
IllegalDropModification = Class.new(Jekyll::StandardError)
|
||||||
|
|
||||||
def initialize(obj)
|
def initialize(obj)
|
||||||
@obj = obj
|
@obj = obj
|
||||||
|
@ -18,7 +19,7 @@ module Jekyll
|
||||||
|
|
||||||
def []=(key, val)
|
def []=(key, val)
|
||||||
if respond_to? key
|
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
|
else
|
||||||
fallback_data[key] = val
|
fallback_data[key] = val
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue