Module: Hyrax::Renderers::ConfiguredMicrodata

Included in:
AttributeRenderer
Defined in:
app/renderers/hyrax/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
# File 'app/renderers/hyrax/renderers/configured_microdata.rb', line 4

def microdata?(field)
  return false unless Hyrax.config.display_microdata?
  translate_microdata(field: field, field_context: 'property', default: false)
end

#microdata_object?(field) ⇒ Boolean

Returns:

  • (Boolean)

Since:

  • 0.14.0



9
10
11
12
# File 'app/renderers/hyrax/renderers/configured_microdata.rb', line 9

def microdata_object?(field)
  return false unless Hyrax.config.display_microdata?
  translate_microdata(field: field, field_context: 'type', default: false)
end

#microdata_object_attributes(field) ⇒ Object

Since:

  • 0.14.0



14
15
16
17
18
19
20
# File 'app/renderers/hyrax/renderers/configured_microdata.rb', line 14

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



22
23
24
# File 'app/renderers/hyrax/renderers/configured_microdata.rb', line 22

def microdata_property(field)
  translate_microdata(field: field, field_context: 'property')
end

#microdata_type(field) ⇒ Object

Since:

  • 0.14.0



26
27
28
# File 'app/renderers/hyrax/renderers/configured_microdata.rb', line 26

def microdata_type(field)
  translate_microdata(field: field, field_context: 'type')
end

#microdata_value_attributes(field) ⇒ Object

Since:

  • 0.14.0



30
31
32
33
34
35
36
37
# File 'app/renderers/hyrax/renderers/configured_microdata.rb', line 30

def microdata_value_attributes(field)
  if microdata?(field)
    field_context = microdata_object?(field) ? :value : :property
    { itemprop: translate_microdata(field: field, field_context: field_context) }
  else
    {}
  end
end