Module: CurationConcerns::Renderers::ConfiguredMicrodata

Included in:
AttributeRenderer
Defined in:
app/renderers/curation_concerns/renderers/configured_microdata.rb

Overview

Since:

  • 0.14.0

Instance Method Summary collapse

Instance Method Details

#microdata?(field) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.14.0



4
5
6
7
8
# File 'app/renderers/curation_concerns/renderers/configured_microdata.rb', line 4

def microdata?(field)
  return false unless CurationConcerns.config.display_microdata
  key = "curation_concerns.schema_org.#{field}.property"
  t(key, default: false)
end

#microdata_object?(field) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.14.0



10
11
12
13
14
# File 'app/renderers/curation_concerns/renderers/configured_microdata.rb', line 10

def microdata_object?(field)
  return false unless CurationConcerns.config.display_microdata
  key = "curation_concerns.schema_org.#{field}.type"
  t(key, default: false)
end

#microdata_object_attributes(field) ⇒ Object

Since:

  • 0.14.0



16
17
18
19
20
21
22
# File 'app/renderers/curation_concerns/renderers/configured_microdata.rb', line 16

def microdata_object_attributes(field)
  if microdata_object?(field)
    { itemprop: microdata_property(field), itemscope: '', itemtype: microdata_type(field) }
  else
    {}
  end
end

#microdata_property(field) ⇒ Object

Since:

  • 0.14.0



24
25
26
# File 'app/renderers/curation_concerns/renderers/configured_microdata.rb', line 24

def microdata_property(field)
  t("curation_concerns.schema_org.#{field}.property")
end

#microdata_type(field) ⇒ Object

Since:

  • 0.14.0



28
29
30
# File 'app/renderers/curation_concerns/renderers/configured_microdata.rb', line 28

def microdata_type(field)
  t("curation_concerns.schema_org.#{field}.type")
end

#microdata_value_attributes(field) ⇒ Object

Since:

  • 0.14.0



32
33
34
35
36
37
38
39
# File 'app/renderers/curation_concerns/renderers/configured_microdata.rb', line 32

def microdata_value_attributes(field)
  if microdata?(field)
    key = microdata_object?(field) ? :value : :property
    { itemprop: t("curation_concerns.schema_org.#{field}.#{key}") }
  else
    {}
  end
end