Module: Threatstack::Serializable

Included in:
Agent, Alert, Event, Log, Organization, Policy, Rule, UserIdentity
Defined in:
lib/threatstack/serializable.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



13
14
15
# File 'lib/threatstack/serializable.rb', line 13

def method_missing(m, *args)
  raw[m.to_s]
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



3
4
5
# File 'lib/threatstack/serializable.rb', line 3

def raw
  @raw
end

Class Method Details

.included(base) ⇒ Object



5
6
7
# File 'lib/threatstack/serializable.rb', line 5

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#attrsObject



17
18
19
# File 'lib/threatstack/serializable.rb', line 17

def attrs
  @attrs ||= self.class.default_attrs + raw.keys.map(&:to_sym)
end

#initialize(raw) ⇒ Object



9
10
11
# File 'lib/threatstack/serializable.rb', line 9

def initialize(raw)
  @raw = raw
end