Skip to content
This repository has been archived by the owner on Apr 5, 2023. It is now read-only.

mcls/setting_macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Code of conduct

Stars

Watchers

Forks

Packages

No packages published