Class: Podium::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/podium/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_mappingObject (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