Created
June 29, 2014 04:33
-
-
Save walski/c59cb5e292c7a042a0a0 to your computer and use it in GitHub Desktop.
That would be nice
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
# what if… | |
class Config | |
def initialize(path) | |
@data = YAML.parse_file(path) | |
end | |
protected | |
def root_path | |
@root_path ||= @data['app']['root_path'] | |
end | |
end |
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
# … could be written like this | |
class Config | |
# "incoming" filters. Used when writing that attribute | |
@data << YAML.parse_file | |
# "outgoing" filters. Used when reading that attribute | |
@root_path >> @data['app']['base_path'] | |
# Also: No extra lambda/Proc notation | |
# One line method definitions | |
def initialize(@data = path) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment