Sha256: 659b0909bacdf8c531395384fbb2b0241a0c00e82fbca43f1aac55e0d55cdfad

Contents?: true

Size: 864 Bytes

Versions: 11

Compression:

Stored size: 864 Bytes

Contents

module DataMapper
  class Property

    def to_json_schema_hash(repo)

      tm = repository(repo).adapter.type_map
      type_information = tm[type]
      if type_information.nil? && type.respond_to?(:primitive)
        type_information = tm[type.primitive]
      end
      
      json_hash = Hash.new
      json_hash = {      "type"      => type_information[:primitive] }
      json_hash.merge!({ "optional"  => true })       unless required?
      json_hash.merge!({ "unique"    => true})        if     unique?
      json_hash.merge!({ "position"  => @position })  unless @position.nil?
      json_hash.merge!({ "prefix"    => @prefix })    unless @prefix.nil?
      json_hash.merge!({ "separator" => @separator }) unless @separator.nil?
      json_hash.merge!(  type_information.reject{ |key,value| key == :primitive } )

      json_hash
    end
    
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dm-persevere-adapter-0.71.4 lib/dm/property.rb
dm-persevere-adapter-0.71.3 lib/dm/property.rb
dm-persevere-adapter-0.71.2 lib/dm/property.rb
dm-persevere-adapter-0.71.1 lib/dm/property.rb
dm-persevere-adapter-0.71.0 lib/dm/property.rb
dm-persevere-adapter-0.70.0 lib/dm/property.rb
dm-persevere-adapter-0.60.5 lib/dm/property.rb
dm-persevere-adapter-0.60.4 lib/dm/property.rb
dm-persevere-adapter-0.60.3 lib/dm/property.rb
dm-persevere-adapter-0.60.2 lib/dm/property.rb
dm-persevere-adapter-0.60.1 lib/dm/property.rb