Module: LinkedRails::Collection::IRI

Extended by:
ActiveSupport::Concern
Included in:
LinkedRails::Collection
Defined in:
app/models/linked_rails/collection/iri.rb

Constant Summary collapse

DEFAULT_IRI_TEMPLATE_KEYS =
%i[before%5B%5D display filter%5B%5D page page_size sort%5B%5D table_type title type].freeze

Instance Method Summary collapse

Instance Method Details

#iri_optsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/linked_rails/collection/iri.rb', line 10

def iri_opts
  {
    parent_iri: parent_iri,
    display: @display,
    table_type: @table_type,
    title: @title,
    type: @type,
    page_size: @page_size,
    filter: self.class.filter_iri_opts(@filter),
    route_key: route_key,
    sort: self.class.sort_iri_opts(@sort)
  }.compact
end

#iri_template_optsObject



24
25
26
27
# File 'app/models/linked_rails/collection/iri.rb', line 24

def iri_template_opts
  opts = iri_opts.with_indifferent_access.slice(*(DEFAULT_IRI_TEMPLATE_KEYS + iri_template_keys))
  Hash[opts.keys.map { |key| [CGI.unescape(key).sub('[]', ''), opts[key]] }].to_param
end

#serialized_iri_templateObject



29
30
31
32
33
34
# File 'app/models/linked_rails/collection/iri.rb', line 29

def serialized_iri_template
  iri_template
    .to_s
    .gsub('{route_key}', iri_template_route_key)
    .gsub('{/parent_iri*}', iri_template_parent_iri)
end