Sha256: 9f299cd1715748e873bb1082a9cfea9f44d648d6dcfbba7e9096d8895d60a876
Contents?: true
Size: 676 Bytes
Versions: 11
Compression:
Stored size: 676 Bytes
Contents
module Spectifly module Json class Field < Spectifly::Base::Field def to_h fields = { :type => type, :multiple => multiple?, :required => required?, } [:description, :example, :validations, :restrictions].each do |opt| value = self.send(opt) if value && !value.empty? fields[opt] = value end end { name.to_sym => fields} end def restrictions @restrictions.inject({}) do |result, (type, value)| value = value.source if type == 'regex' result[type] = value result end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems