Class: Object

Inherits:
BasicObject
Defined in:
lib/gems/json_pure-1.1.3/lib/json/add/rails.rb,
lib/gems/dm-validations-0.9.9/lib/dm-validations/support/object.rb

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/gems/json_pure-1.1.3/lib/json/add/rails.rb', line 10

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

Instance Method Details

#to_json(*a) ⇒ Object



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

def to_json(*a)
  result = {
    'json_class' => 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

#validatable?Boolean

Returns:



2
3
4
# File 'lib/gems/dm-validations-0.9.9/lib/dm-validations/support/object.rb', line 2

def validatable?
  false
end