class OneSignal::BaseModel

Public Class Methods

new(attributes = {}) click to toggle source
# File lib/onesignal/models/base_model.rb, line 7
def initialize(attributes = {})
  attributes.each do |key, value|
    create_attr(key)
    send("#{key}=", value)
  end
end
to_proc() click to toggle source
# File lib/onesignal/models/base_model.rb, line 3
def self.to_proc
  method(:new).to_proc
end

Public Instance Methods

inspect() click to toggle source
# File lib/onesignal/models/base_model.rb, line 14
def inspect
  values = Hash[
    instance_variables.map { |name| [name, instance_variable_get(name)] }
  ]

  "<#{self.class.name} #{values}>"
end

Private Instance Methods

create_attr(name) click to toggle source
# File lib/onesignal/models/base_model.rb, line 24
def create_attr(name)
  create_method("#{name}=".to_sym) do |value|
    instance_variable_set("@#{name}", value)
  end

  create_method(name.to_sym) do
    instance_variable_get("@#{name}")
  end
end
create_method(name, &block) click to toggle source
# File lib/onesignal/models/base_model.rb, line 34
def create_method(name, &block)
  unless respond_to?(name)
    self.class.send(:define_method, name, &block)
  end
end