Class: Podium::Client
- Inherits:
-
Object
- Object
- Podium::Client
- Defined in:
- lib/podium/client.rb
Instance Attribute Summary collapse
-
#podlet_mapping ⇒ Object
readonly
Returns the value of attribute podlet_mapping.
Instance Method Summary collapse
-
#initialize(name_to_url: nil) ⇒ Client
constructor
A new instance of Client.
- #load_content_for_podlets(podlet_names, context) ⇒ Object
- #podlet_resources(names) ⇒ Object
- #register(name, uri = nil) ⇒ Object
Constructor Details
#initialize(name_to_url: nil) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 |
# File 'lib/podium/client.rb', line 5 def initialize(name_to_url: nil) @name_to_url = name_to_url @podlet_mapping = {} @resources = {} end |
Instance Attribute Details
#podlet_mapping ⇒ Object (readonly)
Returns the value of attribute podlet_mapping.
3 4 5 |
# File 'lib/podium/client.rb', line 3 def podlet_mapping @podlet_mapping end |
Instance Method Details
#load_content_for_podlets(podlet_names, context) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/podium/client.rb', line 16 def load_content_for_podlets(podlet_names, context) podlet_resources(podlet_names).reduce({}) do |acc, resource| acc[resource.name] = resource.fetch(context) acc end end |
#podlet_resources(names) ⇒ Object
23 24 25 |
# File 'lib/podium/client.rb', line 23 def podlet_resources(names) names.map { |name| resources[name] ||= Resource.new(podlet_uri(name), name) } end |
#register(name, uri = nil) ⇒ Object
11 12 13 14 |
# File 'lib/podium/client.rb', line 11 def register(name, uri = nil) uri ||= determine_uri(name) podlet_mapping[name] = uri end |