Created
June 16, 2012 05:34
-
-
Save meskallito/2940085 to your computer and use it in GitHub Desktop.
using ActiveSupport::Configurable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee | |
include ActiveSupport::Configurable | |
end | |
employee = Employee.new | |
employee.config.research_lab_entry = :not_allowed | |
employee.config.paid_leave = 5 | |
class Employee | |
include ActiveSupport::Configurable | |
config_accessor :research_lab_entry, :paid_leave | |
# The config options are now also available as: | |
# employee.research_lab_entry | |
# employee.paid_leave | |
end | |
# Set the config option at the class level | |
Employee.config.paid_leave = 5 | |
# Create a new object and check the value | |
employee = Employee.new | |
employee.config.paid_leave # => 5 | |
# Set a new value at the object-level | |
employee.config.paid_leave = 3 | |
# Now check the value at the class level | |
Employee.config.paid_leave # => 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment