Module: NetboxClientRuby::Entities::ClassMethods
- Defined in:
- lib/netbox_client_ruby/entities.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check_limit(limit) ⇒ Object
- #count_key(key = 'count') ⇒ Object
- #data_key(key = 'data') ⇒ Object
- #entity_creator(creator = nil) ⇒ Object
- #limit(limit = nil) ⇒ Object
- #path(path = nil) ⇒ Object
Class Method Details
.extended(other_klass) ⇒ Object
13 14 15 |
# File 'lib/netbox_client_ruby/entities.rb', line 13 def self.extended(other_klass) @other_klass = other_klass end |
Instance Method Details
#check_limit(limit) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/netbox_client_ruby/entities.rb', line 40 def check_limit(limit) max_limit = NetboxClientRuby.config.netbox.pagination.max_limit if limit.nil? raise ArgumentError, "'limit' can not be nil." elsif !limit.is_a?(Numeric) raise ArgumentError, "The limit '#{limit}' is not numeric but it has to be." elsif !limit.integer? raise ArgumentError, "The limit '#{limit}' is not integer but it has to be." elsif limit.negative? raise ArgumentError, "The limit '#{limit}' is below zero, but it should be zero or bigger." elsif limit > max_limit raise ArgumentError, "The limit '#{limit}' is bigger than the configured limit value ('#{max_limit}')." end end |
#count_key(key = 'count') ⇒ Object
21 22 23 |
# File 'lib/netbox_client_ruby/entities.rb', line 21 def count_key(key = 'count') @count_key ||= key end |
#data_key(key = 'data') ⇒ Object
17 18 19 |
# File 'lib/netbox_client_ruby/entities.rb', line 17 def data_key(key = 'data') @data_key ||= key end |
#entity_creator(creator = nil) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/netbox_client_ruby/entities.rb', line 60 def entity_creator(creator = nil) return @entity_creator if @entity_creator raise ArgumentError, '"entity_creator" has not been defined.' unless creator @entity_creator = creator end |
#limit(limit = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/netbox_client_ruby/entities.rb', line 25 def limit(limit = nil) return @limit if @limit @limit = limit || NetboxClientRuby.config.netbox.pagination.default_limit if @limit.nil? raise ArgumentError, "Whether 'limit' nor 'default_limit' are defined." end check_limit @limit @limit end |
#path(path = nil) ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/netbox_client_ruby/entities.rb', line 68 def path(path = nil) return @path if @path raise ArgumentError, '"path" has not been defined.' unless path @path = path end |