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



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

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



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

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



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

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



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

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

#microdata_type(field) ⇒ Object

Since:

  • 0.14.0



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

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

#microdata_value_attributes(field) ⇒ Object

Since:

  • 0.14.0



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

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