class PactBroker::DB::Clean::Selector

Constants

ATTRIBUTES

Public Class Methods

from_hash(hash) click to toggle source
# File lib/pact_broker/db/clean/selector.rb, line 20
def self.from_hash(hash)
  standard_hash = hash.symbolize_keys.snakecase_keys
  new_hash = standard_hash.slice(*ATTRIBUTES)
  new_hash[:pacticipant_name] ||= standard_hash[:pacticipant] if standard_hash[:pacticipant]
  new_hash[:environment_name] ||= standard_hash[:environment] if standard_hash[:environment]
  new_hash[:source_hash] = hash
  new(new_hash.compact)
end
new(attributes = {}) click to toggle source
# File lib/pact_broker/db/clean/selector.rb, line 13
def initialize(attributes = {})
  attributes.each do | (name, value) |
    instance_variable_set("@#{name}", value) if respond_to?(name)
  end
  @source_hash = attributes[:source_hash]
end

Public Instance Methods

currently_deployed?() click to toggle source
# File lib/pact_broker/db/clean/selector.rb, line 40
def currently_deployed?
  !!deployed
end
currently_supported?() click to toggle source
# File lib/pact_broker/db/clean/selector.rb, line 44
def currently_supported?
  !!released
end
latest?() click to toggle source
# File lib/pact_broker/db/clean/selector.rb, line 48
def latest?
  !!latest
end
to_h()
Alias for: to_hash
to_hash() click to toggle source
# File lib/pact_broker/db/clean/selector.rb, line 29
def to_hash
  ATTRIBUTES.each_with_object({}) do | key, hash |
    hash[key] = send(key)
  end.compact
end
Also aliased as: to_h
to_json(_opts = nil) click to toggle source
# File lib/pact_broker/db/clean/selector.rb, line 36
def to_json(_opts = nil)
  (@source_hash || to_hash).to_json
end