Module: Hsquare
- Defined in:
- lib/hsquare.rb,
lib/hsquare/client.rb,
lib/hsquare/device.rb,
lib/hsquare/version.rb,
lib/hsquare/application.rb,
lib/hsquare/notification.rb,
lib/hsquare/configuration.rb
Defined Under Namespace
Classes: Application, Client, Configuration, Device, Notification
Constant Summary collapse
- VERSION =
'0.0.4'
Class Method Summary collapse
-
.application(label = nil) ⇒ Object
Public: Finds application with given label.
-
.apply(configuration) ⇒ Object
Public: Applies given configuration.
-
.config ⇒ Object
Public: Configures Hsquare with given block.
Class Method Details
.application(label = nil) ⇒ Object
Public: Finds application with given label.
label - Label of the applcation.
Returns registered Hsquare::Application object.
51 52 53 54 55 56 57 |
# File 'lib/hsquare.rb', line 51 def self.application(label = nil) if label @configuration.applications.detect { |application| application.label == label.to_sym } || @configuration.default_application else @configuration.default_application end end |
.apply(configuration) ⇒ Object
Public: Applies given configuration.
Returns nothing.
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/hsquare.rb', line 34 def self.apply(configuration) if configuration.http_proxy http_proxy_uri = URI.parse(configuration.http_proxy) Hsquare::Client.http_proxy http_proxy_uri.host, http_proxy_uri.port end configuration.applications.each(&:refresh_admin_client) @configuration = configuration end |
.config ⇒ Object
Public: Configures Hsquare with given block.
Examples
Hsqure.config do |config|
config.admin_key = # Admin key obtained from Kakao Developers
end
Returns newly set configuration.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hsquare.rb', line 20 def self.config if block_given? Hsquare::Configuration.new.tap do |configuration| yield(configuration) apply(configuration) end else @configuration ||= Hsquare::Configuration.new end end |