Skip to content

Commit

Permalink
Add a reasonable to_s method to models
Browse files Browse the repository at this point in the history
  • Loading branch information
egypt committed Jul 24, 2014
1 parent fe0e8cb commit 4d3dc16
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/models/metasploit/credential/private.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,16 @@ class Metasploit::Credential::Private < ActiveRecord::Base
scope: :type
}

#
# Instance Methods
#

# A string suitable for displaying to the user
#
# @return [String]
def to_s
data.to_s
end

Metasploit::Concern.run(self)
end
11 changes: 11 additions & 0 deletions app/models/metasploit/credential/public.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,16 @@ class Metasploit::Credential::Public < ActiveRecord::Base
presence: true,
uniqueness: true

#
# Instance Methods
#

# A string suitable for displaying to the user
#
# @return [String]
def to_s
username.to_s
end

Metasploit::Concern.run(self)
end
9 changes: 9 additions & 0 deletions app/models/metasploit/credential/realm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,14 @@ def self.key_set
@key_set ||= Set.new Metasploit::Model::Realm::Key::ALL
end

#
# Instance Methods
#

# @return [String]
def to_s
value.to_s
end

Metasploit::Concern.run(self)
end
8 changes: 8 additions & 0 deletions app/models/metasploit/credential/ssh_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ def private?
end
end

# The {#data key data}'s fingerprint, suitable for displaying to the
# user.
#
# @return [String]
def to_s
data ? openssl_pkey_pkey.fingerprint : ''
end

private

# Converts the private key file data in {#data} to an `OpenSSL::PKey::PKey` subclass instance.
Expand Down

0 comments on commit 4d3dc16

Please sign in to comment.