Module: Configurable
- Included in:
- Perfetto::Configure
- Defined in:
- lib/perfetto/core_ext/configurable.rb
Overview
Copy-pasted from github.com/midori-rb/midori.rb/blob/master/lib/midori/core_ext/configurable.rb rubocop:disable Style/OptionalBooleanParameter rubocop:disable Style/DocumentDynamicEvalDefinition
Instance Method Summary collapse
-
#set(option, value = (not_set = true), read_only = false) ⇒ nil
Sets an option to the given value.
Instance Method Details
#set(option, value = (not_set = true), read_only = false) ⇒ nil
Sets an option to the given value.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/perfetto/core_ext/configurable.rb', line 12 def set(option, value = (not_set = true), read_only = false) raise ArgumentError if not_set setter = proc { |val| set option, val } getter = proc { value } define_singleton("#{option}=", setter) unless read_only define_singleton(option, getter) define_singleton("#{option}?", "!!#{option}") unless method_defined? "#{option}?" self end |