Module: GreenMonkey::ModelHelpers::ClassMethods

Defined in:
lib/green_monkey/ext/active_model.rb

Instance Method Summary collapse

Instance Method Details

#html_schema_type(value = nil, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/green_monkey/ext/active_model.rb', line 15

def html_schema_type(value = nil, options = {})
  return @html_schema_type unless value

  if const = Mida::Vocabulary.try_load_const(value)
    value = const
  else
    value = /#{value}/ if value.is_a?(Symbol)

    if value.is_a?(Regexp)
      value = Mida::Vocabulary.vocabularies.find do |vocabulary|
        vocabulary.itemtype.to_s =~ value && vocabulary.itemtype.to_s
      end
    end
  end

  @html_schema_type = value
  @html_schema_options = options
end