Class: LightrateClient::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/lightrate_client/types.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:, refill_rate:, burst_rate:, is_default: false, matcher: nil, http_method: nil) ⇒ Rule

Returns a new instance of Rule.



94
95
96
97
98
99
100
101
102
# File 'lib/lightrate_client/types.rb', line 94

def initialize(id:, name:, refill_rate:, burst_rate:, is_default: false, matcher: nil, http_method: nil)
  @id = id
  @name = name
  @refill_rate = refill_rate
  @burst_rate = burst_rate
  @is_default = is_default
  @matcher = matcher
  @http_method = http_method
end

Instance Attribute Details

#burst_rateObject (readonly)

Returns the value of attribute burst_rate.



92
93
94
# File 'lib/lightrate_client/types.rb', line 92

def burst_rate
  @burst_rate
end

#http_methodObject (readonly)

Returns the value of attribute http_method.



92
93
94
# File 'lib/lightrate_client/types.rb', line 92

def http_method
  @http_method
end

#idObject (readonly)

Returns the value of attribute id.



92
93
94
# File 'lib/lightrate_client/types.rb', line 92

def id
  @id
end

#is_defaultObject (readonly)

Returns the value of attribute is_default.



92
93
94
# File 'lib/lightrate_client/types.rb', line 92

def is_default
  @is_default
end

#matcherObject (readonly)

Returns the value of attribute matcher.



92
93
94
# File 'lib/lightrate_client/types.rb', line 92

def matcher
  @matcher
end

#nameObject (readonly)

Returns the value of attribute name.



92
93
94
# File 'lib/lightrate_client/types.rb', line 92

def name
  @name
end

#refill_rateObject (readonly)

Returns the value of attribute refill_rate.



92
93
94
# File 'lib/lightrate_client/types.rb', line 92

def refill_rate
  @refill_rate
end

Class Method Details

.from_hash(hash) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/lightrate_client/types.rb', line 104

def self.from_hash(hash)
  new(
    id: hash['id'] || hash[:id],
    name: hash['name'] || hash[:name],
    refill_rate: hash['refillRate'] || hash[:refill_rate],
    burst_rate: hash['burstRate'] || hash[:burst_rate],
    is_default: hash['isDefault'] || hash[:is_default] || false,
    matcher: hash['matcher'] || hash[:matcher],
    http_method: hash['httpMethod'] || hash[:http_method]
  )
end