Module: OrientDB::SQL

Defined in:
lib/orientdb/sql.rb,
lib/orientdb/sql/ext.rb,
lib/orientdb/sql/query.rb,
lib/orientdb/sql/common.rb,
lib/orientdb/sql/delete.rb,
lib/orientdb/sql/insert.rb,
lib/orientdb/sql/update.rb

Defined Under Namespace

Modules: BundledFunctionExtension, ClassClusterParametersMixin, ConditionalExtension, ConditionsParametersMixin, FieldOperatorExtension, FieldsValuesParametersMixin, OrderExtension, UtilsMixin Classes: ConditionExpression, Delete, Insert, LiteralExpression, Query, SQLSynchQuery, Update

Class Method Summary collapse

Class Method Details

.monkey_patch!(*args) ⇒ Object

Extend strings and/or symbols to create queries easier



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/orientdb/sql/ext.rb', line 17

def monkey_patch!(*args)
  args = %w{ symbol string } if args.empty?
  args.each do |arg|
    case arg.to_s.downcase.to_sym
      when :symbol
        if monkey_patched?(:symbol)
          puts "Symbol has already been monkey patched!"
          false
        else
          Symbol.send :include, OrderExtension
          Symbol.send :include, ConditionalExtension
          Symbol.send :include, FieldOperatorExtension
          Symbol.send :include, BundledFunctionExtension
          monkey_patched << :symbol
          true
        end
      when :string
        if monkey_patched?(:string)
          puts "String has already been monkey patched!"
          false
        else
          String.send :include, OrderExtension
          String.send :include, ConditionalExtension
          String.send :include, FieldOperatorExtension
          String.send :include, BundledFunctionExtension
          monkey_patched << :string
          true
        end
    end
  end
end

.monkey_patchedObject



4
5
6
# File 'lib/orientdb/sql/ext.rb', line 4

def monkey_patched
  @monkey_patched ||= []
end

.monkey_patched?(name) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/orientdb/sql/ext.rb', line 10

def monkey_patched?(name)
  monkey_patched.include? name.to_s.downcase.to_sym
end