Sha256: 2e41e9a9b7de32378c4f509704ede9a50df19995d66ce79e28befdc876d211ba

Contents?: true

Size: 614 Bytes

Versions: 8

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true
# This is a helper class. It lets you build simple DSL's. Methods called against the class are
# converted into attributes in a hash.
module GraphQL
  module Models
    class Definer
      def initialize(*methods)
        @values = {}
        methods.each do |m|
          define_singleton_method(m) do |*args|
            @values[m] = if args.blank?
              nil
            elsif args.length == 1
              args[0]
            else
              args
            end
          end
        end
      end

      def defined_values
        @values
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-activerecord-0.12.6 lib/graphql/models/definer.rb
graphql-activerecord-0.12.5 lib/graphql/models/definer.rb
graphql-activerecord-0.12.4 lib/graphql/models/definer.rb
graphql-activerecord-0.12.3 lib/graphql/models/definer.rb
graphql-activerecord-0.12.2 lib/graphql/models/definer.rb
graphql-activerecord-0.12.1 lib/graphql/models/definer.rb
graphql-activerecord-0.12.0 lib/graphql/models/definer.rb
graphql-activerecord-0.11.0 lib/graphql/models/definer.rb