module Threatstack::Serializable
Attributes
client[R]
raw[R]
Public Class Methods
included(base)
click to toggle source
# File lib/threatstack/serializable.rb, line 5 def self.included(base) base.extend ClassMethods end
new(raw, client, entity: nil)
click to toggle source
# File lib/threatstack/serializable.rb, line 9 def initialize(raw, client, entity: nil) @client = client @raw = raw @entity = entity end
Public Instance Methods
attrs()
click to toggle source
# File lib/threatstack/serializable.rb, line 19 def attrs @attrs ||= self.class.default_attrs end
camelize(str)
click to toggle source
# File lib/threatstack/serializable.rb, line 23 def camelize(str) string = str.sub(/^(?:(?=\b|[A-Z_])|\w)/) { $&.downcase } string.gsub(/(?:_|(\/))([a-z\d]*)/) { "#{$1}#{$2.capitalize}" }.gsub('/', '::') end
method_missing(m, *args)
click to toggle source
# File lib/threatstack/serializable.rb, line 15 def method_missing(m, *args) raw[m.to_s] || raw[camelize(m.to_s)] end