class Rebrandly::Element

General class to map Rebrandly objects to Ruby objects

Public Class Methods

new(attrs={}) click to toggle source
# File lib/rebrandly/element.rb, line 4
def initialize(attrs={})
  # Only set the attributes if the method exists, this way we can ignore deprecated attributes
  attrs.each { |k,v| send("#{k.rebrandly_underscore}=", v) if respond_to?("#{k.rebrandly_underscore}=") }
end

Public Instance Methods

to_h() click to toggle source
# File lib/rebrandly/element.rb, line 9
def to_h
  Hash[
    *instance_variables.map do |variable|
      name = variable[1..-1].to_sym # Drop the @ sign at the front
      [name.to_sym, instance_variable_get(variable)]
    end.flatten
  ]
end