Module: Mac::EventMonitor::JsonSerializable

Included in:
Event, Location
Defined in:
lib/mac-event-monitor/serializable.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/mac-event-monitor/serializable.rb', line 6

def self.included(klass)
  klass.instance_eval do
    def json_create(o)
      new(*o['data'])
    end
  end
end

Instance Method Details

#to_json(*a) ⇒ Object



14
15
16
17
18
19
# File 'lib/mac-event-monitor/serializable.rb', line 14

def to_json(*a)
  {
    'json_class' => self.class.name,
    'data'       => data
  }.to_json(*a)
end