Module: Msf::DBManager::Ref
- Included in:
- Msf::DBManager
- Defined in:
- lib/msf/core/db_manager/ref.rb
Instance Method Summary collapse
-
#find_or_create_ref(opts) ⇒ Object
Find or create a reference matching this name.
- #get_ref(name) ⇒ Object
-
#has_ref?(name) ⇒ Boolean
Find a reference matching this name.
Instance Method Details
#find_or_create_ref(opts) ⇒ Object
Find or create a reference matching this name
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/msf/core/db_manager/ref.rb', line 5 def find_or_create_ref(opts) ret = {} ::ApplicationRecord.connection_pool.with_connection { if opts[:id] && !opts[:id].to_s.empty? return Mdm::Ref.find(opts[:id]) end if opts[:ref] return get_ref(opts[:name]) end ref = ::Mdm::Ref.where(name: opts[:name]).first_or_initialize begin framework.events.on_db_ref(ref) if ref rescue ::Exception => e wlog("Exception in on_db_ref event handler: #{e.class}: #{e}") wlog("Call Stack\n#{e.backtrace.join("\n")}") end if ref and ref.changed? ref.save! end ref } end |
#get_ref(name) ⇒ Object
33 34 35 36 37 |
# File 'lib/msf/core/db_manager/ref.rb', line 33 def get_ref(name) ::ApplicationRecord.connection_pool.with_connection { ::Mdm::Ref.find_by_name(name) } end |
#has_ref?(name) ⇒ Boolean
Find a reference matching this name
42 43 44 45 46 |
# File 'lib/msf/core/db_manager/ref.rb', line 42 def has_ref?(name) ::ApplicationRecord.connection_pool.with_connection { Mdm::Ref.find_by_name(name) } end |