Created
August 27, 2014 15:22
-
-
Save efatsi/9adcb852f05a03bf49b6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module RubySpark | |
module Configuration | |
def self.included(base) | |
base.extend ClassMethods | |
end | |
module ClassMethods | |
def configuration | |
yield self | |
end | |
def define_setting(name, default = nil) | |
class_variable_set("@@#{name}", default) | |
define_class_method "#{name}=" do |value| | |
class_variable_set("@@#{name}", value) | |
end | |
define_class_method name do | |
class_variable_get("@@#{name}") | |
end | |
end | |
private | |
def define_class_method(name, &block) | |
(class << self; self; end).instance_eval do | |
define_method name, &block | |
end | |
end | |
end | |
end | |
end |
This file contains hidden or 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
require 'ruby_spark/helpers/configuration' | |
module RubySpark | |
include Configuration | |
define_setting :access_token | |
define_setting :timeout, 30 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment