Skip to content

Instantly share code, notes, and snippets.

@walski
Created June 29, 2014 04:33
Show Gist options
  • Save walski/c59cb5e292c7a042a0a0 to your computer and use it in GitHub Desktop.
Save walski/c59cb5e292c7a042a0a0 to your computer and use it in GitHub Desktop.
That would be nice
# 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
# … 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