Class: Ugc::Application
- Inherits:
-
Usergrid::Application
- Object
- Usergrid::Application
- Ugc::Application
- Defined in:
- lib/ugc/application.rb
Instance Method Summary collapse
- #[](uri) ⇒ Object
- #application_url ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #list_collections ⇒ Object
- #login(username, password) ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
4 5 6 7 |
# File 'lib/ugc/application.rb', line 4 def initialize super application_url self.auth_token = $settings.access_token end |
Instance Method Details
#[](uri) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/ugc/application.rb', line 24 def [](uri) uri = perform_substitutions uri if (URI.parse(uri).host rescue nil) Usergrid::Resource.new(uri, nil, $application.) # absolute else super # relative end end |
#application_url ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/ugc/application.rb', line 9 def application_url url = $settings.base_url org = $settings.organization app = $settings.application raise "not configured" unless url && org && app concat_urls url, "#{org}/#{app}" end |
#list_collections ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ugc/application.rb', line 33 def list_collections app = $application.entity collections = app['metadata']['collections'] table border: $settings.table_border? do row header: true do collections.first[1].each_key do |k| column k end end collections.each_value do |coll| row do coll.each_value do |v| column v end end end end end |
#login(username, password) ⇒ Object
19 20 21 22 |
# File 'lib/ugc/application.rb', line 19 def login(username, password) super username, password $settings.access_token = auth_token end |