fluentd-ui/app/models/fluentd/setting/section.rb
Kenji Okimoto 58f5ab3b10
Construct section class properly
In previous version, run merged block before calling init.

Signed-off-by: Kenji Okimoto <okimoto@clear-code.com>
2018-05-28 14:58:02 +09:00

39 lines
923 B
Ruby

class Fluentd
module Setting
class Section
class << self
def inherited(klass)
klass.instance_eval do
include ActiveModel::Model
include ActiveModel::Attributes
include Fluentd::Setting::Configurable
include Fluentd::Setting::SectionParser
include Fluentd::Setting::PluginParameter
class_attribute :_klass, :_block, :_blocks
class_attribute :section_name, :required, :multi, :alias
self._klass = klass
self._blocks = []
end
end
def init
_klass.instance_eval(&_block)
_blocks.each do |b|
_klass.instance_eval(&b)
end
end
# Don't overwrite options
def merge(**options, &block)
_blocks << block
end
def section?
true
end
end
end
end
end