Skip to content

Instantly share code, notes, and snippets.

@debajit
Created August 27, 2015 01:15
Show Gist options
  • Save debajit/0aed54eea159714558dc to your computer and use it in GitHub Desktop.
Save debajit/0aed54eea159714558dc to your computer and use it in GitHub Desktop.
Call method when defining Ruby constant
class Updater
METADATA_FILE = self.class.file_path
def initialize
METADATA_FILE
end
def self.file_path
'some file path'
end
end
Updater.new # =>
# ~> -:2:in `<class:Updater>': undefined method `file_path' for Class:Class (NoMethodError)
# ~> from -:1:in `<main>'
@debajit
Copy link
Author

debajit commented Aug 27, 2015

How can I call the file_path method when defining the METADATA_FILE constant?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment