Sha256: 816c99b8ed8af22e96cd118ce8ccd60b82491487c0393cf3e65da842ed85e726
Contents?: true
Size: 973 Bytes
Versions: 5
Compression:
Stored size: 973 Bytes
Contents
module Gorillib module Model # # give each field the next position in order # # @example # class Foo # include Gorillib::Model # field :bob, String # not positional # field :zoe, String, position: 0 # positional 0 (explicit) # end # class Subby < Foo # include Gorillib::Model::PositionalFields # field :wun, String # positional 1 # end # Foo.field :nope, String # not positional # Subby.field :toofer, String # positional 2 # # @note: make sure you're keeping positionals straight in super classes, or # in anything added after this. # module PositionalFields extend Gorillib::Concern module ClassMethods def field(*args) options = args.extract_options! super(*args, {position: positionals.count}.merge(options)) end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems