0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
A module which provides a method to easily define class settings
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.12
~> 10.0
>= 3.4
 Project Readme

SettingMacro

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.

Installation

Add this line to your application's Gemfile:

gem 'setting_macro'

Usage

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'

Contributing

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.