class Contentful::Social::Config

Constants

DEFAULT_ENDPOINT
DEFAULT_PORT

Attributes

config[R]

Public Class Methods

load(path) click to toggle source
# File lib/contentful/social/config.rb, line 12
def self.load(path)
  new(Hashie::Mash.load(path))
end
new(config = {}) click to toggle source
# File lib/contentful/social/config.rb, line 16
def initialize(config = {})
  @config = Hashie::Mash.new(config)

  @config.port = (ENV.key?('PORT') ? ENV['PORT'].to_i : DEFAULT_PORT) unless @config.port?
  @config.endpoint = DEFAULT_ENDPOINT unless @config.endpoint?

  fail 'Contentful Access Token not Configured' unless contentful_configured?
  fail 'No Social Media Configured' unless twitter_configured? || facebook_configured?
end

Public Instance Methods

contentful_configured?() click to toggle source
# File lib/contentful/social/config.rb, line 61
def contentful_configured?
  contentful? &&
    contentful.all? { |space_id, access_token| access_token }
end
endpoint() click to toggle source
# File lib/contentful/social/config.rb, line 30
def endpoint
  @config.endpoint
end
facebook_configured?() click to toggle source
# File lib/contentful/social/config.rb, line 55
def facebook_configured?
  facebook? &&
    facebook.template? &&
    facebook.access_token? # && facebook.app_secret? # not required
end
port() click to toggle source
# File lib/contentful/social/config.rb, line 26
def port
  @config.port
end
twitter_configured?() click to toggle source
# File lib/contentful/social/config.rb, line 46
def twitter_configured?
  twitter? &&
    twitter.template? &&
    twitter.access_token? &&
    twitter.access_token_secret? &&
    twitter.consumer_key? &&
    twitter.consumer_secret?
end