module GreenMonkey::ModelHelpers::ClassMethods

Public Instance Methods

html_schema_type(value = nil, options = {}) click to toggle source
# 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