Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/fiveruns/json/add/rails.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.fjson_create(object) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/fiveruns/json/add/rails.rb', line 7 def self.fjson_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_fjson(*a) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fiveruns/json/add/rails.rb', line 16 def to_fjson(*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_fjson(*a) end |