Sha256: e4e07eb38ffb8f2a0b668e6dde74183c799ca2a09a7ff237d455da1bf0be2dfd

Contents?: true

Size: 610 Bytes

Versions: 32

Compression:

Stored size: 610 Bytes

Contents

# 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|
            if args.blank?
              @values[m] = nil
            elsif args.length == 1
              @values[m] = args[0]
            else
              @values[m] = args
            end
          end
        end
      end

      def defined_values
        @values
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
graphql-activerecord-0.10.0 lib/graphql/models/definer.rb
graphql-activerecord-0.10.0.pre.alpha3 lib/graphql/models/definer.rb
graphql-activerecord-0.10.0.pre.alpha2 lib/graphql/models/definer.rb
graphql-activerecord-0.10.0.pre.alpha1 lib/graphql/models/definer.rb
graphql-activerecord-0.9.1 lib/graphql/models/definer.rb
graphql-activerecord-0.9.0 lib/graphql/models/definer.rb
graphql-activerecord-0.8.0 lib/graphql/models/definer.rb
graphql-activerecord-0.7.3 lib/graphql/models/definer.rb
graphql-activerecord-0.7.2 lib/graphql/models/definer.rb
graphql-activerecord-0.8.0.pre.alpha1 lib/graphql/models/definer.rb
graphql-activerecord-0.7.1 lib/graphql/models/definer.rb
graphql-activerecord-0.7.0 lib/graphql/models/definer.rb
graphql-activerecord-0.6.7 lib/graphql/models/definer.rb
graphql-activerecord-0.6.6 lib/graphql/models/definer.rb
graphql-activerecord-0.6.5 lib/graphql/models/definer.rb
graphql-activerecord-0.6.4 lib/graphql/models/definer.rb
graphql-activerecord-0.6.3 lib/graphql/models/definer.rb
graphql-activerecord-0.6.2 lib/graphql/models/definer.rb
graphql-activerecord-0.6.1 lib/graphql/models/definer.rb
graphql-activerecord-0.6.0 lib/graphql/models/definer.rb