1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00
haml--haml/lib/hamlit/concerns/included.rb
2015-03-29 01:14:20 +09:00

28 lines
680 B
Ruby

# Mini ActiveSupport::Concern
module Hamlit
module Concerns
class MultipleIncludedBlocks < StandardError
def initialize
super "Cannot define multiple 'included' blocks for a Concern"
end
end
module Included
def self.extended(klass)
klass.class_eval do
def self.included(base = nil, &block)
if block_given?
raise MultipleIncludedBlocks if defined?(@_included_block)
@_included_block = block
return
end
base.instance_exec(&@_included_block) if defined?(@_included_block)
super
end
end
end
end
end
end