Sha256: eacb47333e01d82b6c7491435e2e90f91227900dd7e1fb8556d6a30fd487bd48

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

module LinkedRails
  class Form
    class FieldSerializer < LinkedRails.serializer_parent_class
      attribute :name, predicate: Vocab.schema.name
      attribute :description, predicate: Vocab.schema.text
      attribute :helper_text, predicate: Vocab.ontola[:helperText]
      attribute :default_value, predicate: Vocab.form[:defaultValue]

      attribute :datatype, predicate: Vocab.sh.datatype
      attribute :max_count, predicate: Vocab.sh.maxCount
      attribute :max_count_prop, predicate: Vocab.ontola[:maxCount]
      attribute :min_count, predicate: Vocab.sh.minCount
      attribute :min_count_prop, predicate: Vocab.ontola[:minCount]
      attribute :max_inclusive, predicate: Vocab.sh.maxInclusive
      attribute :max_inclusive_prop, predicate: Vocab.ontola[:maxInclusive]
      attribute :min_inclusive, predicate: Vocab.sh.minInclusive
      attribute :min_inclusive_prop, predicate: Vocab.ontola[:minInclusive]
      attribute :max_length, predicate: Vocab.sh.maxLength
      attribute :max_length_prop, predicate: Vocab.ontola[:maxLength]
      attribute :min_length, predicate: Vocab.sh.minLength
      attribute :min_length_prop, predicate: Vocab.ontola[:minLength]
      attribute :pattern, predicate: Vocab.sh.pattern do |object|
        object.pattern.is_a?(Regexp) ? object.pattern.source : object.pattern
      end
      attribute :sh_in, predicate: Vocab.sh.in do |object|
        options = object.sh_in
        if [Array, ActiveRecord::Relation].any? { |klass| options.is_a?(klass) }
          RDF::List[*options.map { |option| option.try(:iri) || option }]
        else
          options
        end
      end
      attribute :sh_in_prop, predicate: Vocab.ontola[:shIn]
      attribute :path, predicate: Vocab.sh.path
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
linked_rails-0.0.4 app/serializers/linked_rails/form/field_serializer.rb
linked_rails-0.0.3 app/serializers/linked_rails/form/field_serializer.rb
linked_rails-0.0.2 app/serializers/linked_rails/form/field_serializer.rb
linked_rails-0.0.1 app/serializers/linked_rails/form/field_serializer.rb