Class: Contentful::Social::Config
- Inherits:
-
Object
- Object
- Contentful::Social::Config
- Defined in:
- lib/contentful/social/config.rb
Constant Summary collapse
- DEFAULT_PORT =
34123- DEFAULT_ENDPOINT =
'/social'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #contentful_configured? ⇒ Boolean
- #endpoint ⇒ Object
- #facebook_configured? ⇒ Boolean
-
#initialize(config = {}) ⇒ Config
constructor
A new instance of Config.
- #port ⇒ Object
- #twitter_configured? ⇒ Boolean
Constructor Details
#initialize(config = {}) ⇒ Config
Returns a new instance of Config.
16 17 18 19 20 21 22 23 24 |
# 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 |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/contentful/social/config.rb', line 10 def config @config end |
Class Method Details
.load(path) ⇒ Object
12 13 14 |
# File 'lib/contentful/social/config.rb', line 12 def self.load(path) new(Hashie::Mash.load(path)) end |
Instance Method Details
#contentful_configured? ⇒ Boolean
61 62 63 64 |
# File 'lib/contentful/social/config.rb', line 61 def contentful_configured? contentful? && contentful.all? { |space_id, access_token| access_token } end |
#endpoint ⇒ Object
30 31 32 |
# File 'lib/contentful/social/config.rb', line 30 def endpoint @config.endpoint end |
#facebook_configured? ⇒ Boolean
55 56 57 58 59 |
# File 'lib/contentful/social/config.rb', line 55 def facebook_configured? facebook? && facebook.template? && facebook.access_token? # && facebook.app_secret? # not required end |
#port ⇒ Object
26 27 28 |
# File 'lib/contentful/social/config.rb', line 26 def port @config.port end |
#twitter_configured? ⇒ Boolean
46 47 48 49 50 51 52 53 |
# 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 |