Class: Object

Inherits:
BasicObject
Defined in:
lib/vendor/thor/lib/thor/rake_compat.rb,
lib/vendor/dataflow/dataflow/equality.rb,
lib/vendor/json_pure/lib/json/add/rails.rb

Overview

The purpose of this file is to make equality use method calls in as many Ruby implementations as possible. If method calls are used, then equality operations using dataflow variaables becomes seemless I realize overriding core classes is a pretty nasty hack, but if you have a better idea that also passes the equality_specs then I’m all ears. Please run the rubyspec before committing changes to this file.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.json_create(object) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/vendor/json_pure/lib/json/add/rails.rb', line 10

def self.json_create(object)
  obj = new
  for key, value in object
    next if key == JSON.create_id
    instance_variable_set "@#{key}", value
  end
  obj
end

Instance Method Details

#==(other) ⇒ Object



9
10
11
# File 'lib/vendor/dataflow/dataflow/equality.rb', line 9

def ==(other)
  object_id == other.object_id
end

#namespace(name, &block) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/vendor/thor/lib/thor/rake_compat.rb', line 55

def namespace(name, &block)
  if klass = Thor::RakeCompat.rake_classes.last
    const_name = Thor::Util.camel_case(name.to_s).to_sym
    klass.const_set(const_name, Class.new(Thor))
    new_klass = klass.const_get(const_name)
    Thor::RakeCompat.rake_classes << new_klass
  end

  rake_namespace(name, &block)
  Thor::RakeCompat.rake_classes.pop
end

#rake_namespaceObject



34
# File 'lib/vendor/thor/lib/thor/rake_compat.rb', line 34

alias :rake_namespace :namespace

#rake_taskObject



33
# File 'lib/vendor/thor/lib/thor/rake_compat.rb', line 33

alias :rake_task :task

#task(*args, &block) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vendor/thor/lib/thor/rake_compat.rb', line 36

def task(*args, &block)
  task = rake_task(*args, &block)

  if klass = Thor::RakeCompat.rake_classes.last
    non_namespaced_name = task.name.split(':').last

    description = non_namespaced_name
    description << task.arg_names.map{ |n| n.to_s.upcase }.join(' ')
    description.strip!

    klass.desc description, task.comment || non_namespaced_name
    klass.send :define_method, non_namespaced_name do |*args|
      Rake::Task[task.name.to_sym].invoke(*args)
    end
  end

  task
end

#to_json(*a) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/vendor/json_pure/lib/json/add/rails.rb', line 19

def to_json(*a)
  result = {
    JSON.create_id => self.class.name
  }
  instance_variables.inject(result) do |r, name|
    r[name[1..-1]] = instance_variable_get name
    r
  end
  result.to_json(*a)
end