lib/linkedin/configuration.rb in linkedin2-0.0.16 vs lib/linkedin/configuration.rb in linkedin2-0.0.17

- old
+ new

@@ -1,42 +1,57 @@ module LinkedIn module Configuration module ClassConfiguration - def config - @config ||= reset + def default_config + { + request_format: :json, + + app_key: nil, + app_secret: nil, + access_token: nil, + + scope: ['r_basicprofile'], + redirect_uri: 'http://localhost', + + logger: Logger.new('/dev/null') + } end + def configuration + @configuration ||= OpenStruct.new default_config + end + def reset - @config = OpenStruct.new default_config + configuration.marshal_load default_config end end module InstanceConfiguration - def config - @config ||= reset + def configuration + @configuration ||= self.class.configuration.dup end def reset - @config = self.class.config.dup + @configuration.marshal_load self.class.configuration end end module BaseConfiguration def configure(config={}, &block) - self.config.marshal_load self.config.marshal_dump.merge(config) + self.configuration.marshal_load self.configuration.marshal_dump.merge(config) - yield self.config if block_given? + yield self.configuration if block_given? - self.config + self.configuration end - def load(file_path='linkedin.yml') + def load(file_path = 'linkedin.yml') config = YAML::load(File.open(file_path)).symbolize_keys configure config end def config(*keys) - config.marshal_dump.slice(*keys) + configuration.marshal_dump.slice(*keys) end end include BaseConfiguration include InstanceConfiguration