module Bandwidth::ApiItem
Module which adds common operations for all Catapult api related classes
Public Class Methods
new(data={}, client = nil)
click to toggle source
Initializer
@param data [Hash] Hash with data of api item. Initializer will create accessors for each key of this hash @param client [Client] Optional client instance. If omitted Client
instance with default parameters will be used
# File lib/bandwidth/api_item.rb, line 8 def initialize(data={}, client = nil) @client = client || Client.new() @data = (data || {}).clone() @data.each do |k,v| self.define_singleton_method(k) do @data[k] end self.define_singleton_method("#{k}=".to_sym()) do |val| @data[k] = val end end end
Public Instance Methods
[](name)
click to toggle source
Return item of @data by name
# File lib/bandwidth/api_item.rb, line 27 def [] (name) @data[name] end
[]=(name, value)
click to toggle source
Set value of @data's item by name
# File lib/bandwidth/api_item.rb, line 32 def []= (name, value) @data[name] = value end
to_data()
click to toggle source
Return data of api item as hash
# File lib/bandwidth/api_item.rb, line 22 def to_data() @data.clone() end