Class: Verizon::DeviceRole
- Defined in:
- lib/verizon/models/device_role.rb
Overview
The access rule (DeviceRole object) defines this topics the application or device can publish or subscribe to. It also defines how many parallel subscriptions one device or applications can have and how fast it can publish messages.
Instance Attribute Summary collapse
-
#name ⇒ String
The unique name of the access rule.
-
#publish ⇒ Array[String]
The topics or topic patterns that the application or device is allowed to publish messages.
-
#publish_rate_limit ⇒ Integer
The maximum rate that one application or device can publish messages per seconds.
-
#subscribe ⇒ Array[String]
The topics or topic patterns that the application or device is allowed to subscribe to.
-
#subscribe_limit ⇒ Integer
The maximum number of subscriptions that one application or device can make.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(name:, subscribe_limit: 50, publish_rate_limit: 15, publish: SKIP, subscribe: SKIP) ⇒ DeviceRole
constructor
A new instance of DeviceRole.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(name:, subscribe_limit: 50, publish_rate_limit: 15, publish: SKIP, subscribe: SKIP) ⇒ DeviceRole
Returns a new instance of DeviceRole.
65 66 67 68 69 70 71 72 |
# File 'lib/verizon/models/device_role.rb', line 65 def initialize(name:, subscribe_limit: 50, publish_rate_limit: 15, publish: SKIP, subscribe: SKIP) @name = name @subscribe_limit = subscribe_limit unless subscribe_limit == SKIP @publish_rate_limit = publish_rate_limit unless publish_rate_limit == SKIP @publish = publish unless publish == SKIP @subscribe = subscribe unless subscribe == SKIP end |
Instance Attribute Details
#name ⇒ String
The unique name of the access rule.
17 18 19 |
# File 'lib/verizon/models/device_role.rb', line 17 def name @name end |
#publish ⇒ Array[String]
The topics or topic patterns that the application or device is allowed to publish messages.
32 33 34 |
# File 'lib/verizon/models/device_role.rb', line 32 def publish @publish end |
#publish_rate_limit ⇒ Integer
The maximum rate that one application or device can publish messages per seconds.
27 28 29 |
# File 'lib/verizon/models/device_role.rb', line 27 def publish_rate_limit @publish_rate_limit end |
#subscribe ⇒ Array[String]
The topics or topic patterns that the application or device is allowed to subscribe to.
37 38 39 |
# File 'lib/verizon/models/device_role.rb', line 37 def subscribe @subscribe end |
#subscribe_limit ⇒ Integer
The maximum number of subscriptions that one application or device can make.
22 23 24 |
# File 'lib/verizon/models/device_role.rb', line 22 def subscribe_limit @subscribe_limit end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/verizon/models/device_role.rb', line 75 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. name = hash.key?('name') ? hash['name'] : nil subscribe_limit = hash['subscribeLimit'] ||= 50 publish_rate_limit = hash['publishRateLimit'] ||= 15 publish = hash.key?('publish') ? hash['publish'] : SKIP subscribe = hash.key?('subscribe') ? hash['subscribe'] : SKIP # Create object from extracted values. DeviceRole.new(name: name, subscribe_limit: subscribe_limit, publish_rate_limit: publish_rate_limit, publish: publish, subscribe: subscribe) end |
.names ⇒ Object
A mapping from model property names to API property names.
40 41 42 43 44 45 46 47 48 |
# File 'lib/verizon/models/device_role.rb', line 40 def self.names @_hash = {} if @_hash.nil? @_hash['name'] = 'name' @_hash['subscribe_limit'] = 'subscribeLimit' @_hash['publish_rate_limit'] = 'publishRateLimit' @_hash['publish'] = 'publish' @_hash['subscribe'] = 'subscribe' @_hash end |
.nullables ⇒ Object
An array for nullable fields
61 62 63 |
# File 'lib/verizon/models/device_role.rb', line 61 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
51 52 53 54 55 56 57 58 |
# File 'lib/verizon/models/device_role.rb', line 51 def self.optionals %w[ subscribe_limit publish_rate_limit publish subscribe ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
101 102 103 104 105 106 |
# File 'lib/verizon/models/device_role.rb', line 101 def inspect class_name = self.class.name.split('::').last "<#{class_name} name: #{@name.inspect}, subscribe_limit: #{@subscribe_limit.inspect},"\ " publish_rate_limit: #{@publish_rate_limit.inspect}, publish: #{@publish.inspect},"\ " subscribe: #{@subscribe.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
94 95 96 97 98 |
# File 'lib/verizon/models/device_role.rb', line 94 def to_s class_name = self.class.name.split('::').last "<#{class_name} name: #{@name}, subscribe_limit: #{@subscribe_limit}, publish_rate_limit:"\ " #{@publish_rate_limit}, publish: #{@publish}, subscribe: #{@subscribe}>" end |