class Rancher::ApiDiscovery::Entity
Public Instance Methods
attributes()
click to toggle source
# File lib/rancher/api_discovery.rb, line 73 def attributes resourceFields.keys end
belongs_to()
click to toggle source
# File lib/rancher/api_discovery.rb, line 67 def belongs_to attributes.select { |k| k.end_with?('Id') }.reject { |k| k.eql?('externalId') }.map do |relation_key| relation_key.gsub('Id', '').downcase end end
code()
click to toggle source
# File lib/rancher/api_discovery.rb, line 77 def code renderer = ERB.new(File.read('./templates/model.erb'), nil, '-') renderer.result(binding) end
has_many()
click to toggle source
# File lib/rancher/api_discovery.rb, line 59 def has_many includeableLinks.map(&:downcase).reject { |k| singular?(k) } end
has_one()
click to toggle source
# File lib/rancher/api_discovery.rb, line 63 def has_one includeableLinks.map(&:downcase).select { |k| singular?(k) } end
helper_filename()
click to toggle source
# File lib/rancher/api_discovery.rb, line 87 def helper_filename "./lib/rancher/api/helpers/#{id}.rb" end
helpers()
click to toggle source
# File lib/rancher/api_discovery.rb, line 82 def helpers return [] unless File.exist?(helper_filename) ["Rancher::Api::Helpers::#{id.capitalize}"] end
Private Instance Methods
singular?(str)
click to toggle source
# File lib/rancher/api_discovery.rb, line 93 def singular?(str) str.singularize == str end