Defines a setting
class method which can be used to retrieve and set some
class-level veriables. Heavily inspired by the ClassMacros in the rom-support
respository.
Add this line to your application's Gemfile:
gem 'setting_macro'
class Heating
extend SettingMacro
setting :default_temperature
setting :heat_source, default: 'unknown'
end
class Oven < Heating
default_temperature 200
end
class Sun < Heating
default_temperature 5505
heat_source 'nuclear_fusion'
end
p Heating.default_temperature # => nil
p Heating.heat_source # => 'unknown'
p Oven.default_temperature # => 200
p Oven.heat_source # => 'unknown'
p Sun.default_temperature # => 5505
p Sun.heat_source # => 'nuclear_fusion'
Bug reports and pull requests are welcome on GitHub at https://github.com/mcls/setting_macro. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.