Sha256: af607de22b327d9cbfda3d81a0b195bee38455d8d1efe6be4d3a18aa5ff78cd4

Contents?: true

Size: 607 Bytes

Versions: 10

Compression:

Stored size: 607 Bytes

Contents

class RestModel
  class Property
    module Builder
      def property(name, options = {})
        options[:validate] = !options[:validate_if_present]
        key Property.new(name, options)
      end

      def properties(*args)
        options = options(args)
        names = args
        names.each {|name| property(name, options)}
      end

      def id(*args)
        options = options(args)
        name = args.fetch(0, :id)
        property(name, options.merge(id: true))
      end

      private

      def options(args)
        args.last.kind_of?(Hash) ? args.pop : {}
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rest_model-0.3.1 lib/rest_model/key/property/builder.rb
rest_model-0.3.0 lib/rest_model/key/property/builder.rb
rest_model-0.2.3 lib/rest_model/key/property/builder.rb
rest_model-0.2.1 lib/rest_model/key/property/builder.rb
rest_model-0.2.0 lib/rest_model/key/property/builder.rb
rest_model-0.1.24 lib/rest_model/key/property/builder.rb
rest_model-0.1.23 lib/rest_model/key/property/builder.rb
rest_model-0.1.22 lib/rest_model/key/property/builder.rb
rest_model-0.1.21 lib/rest_model/key/property/builder.rb
rest_model-0.1.20 lib/rest_model/key/property/builder.rb