Module: Sipity::Queries::AdditionalAttributeQueries

Defined in:
app/repositories/sipity/queries/additional_attribute_queries.rb

Overview

Queries

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sip_attribute_key_value_pairs(sip:, keys: []) ⇒ Object



11
12
13
14
15
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 11

def sip_attribute_key_value_pairs(sip:, keys: [])
  query = Models::AdditionalAttribute.where(sip: sip).order(:sip_id, :key)
  query = query.where(key: keys) if keys.present?
  query.pluck(:key, :value)
end

.sip_attribute_keys_for(sip:) ⇒ Object



19
20
21
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 19

def sip_attribute_keys_for(sip:)
  Models::AdditionalAttribute.where(sip: sip).order(:key).pluck('DISTINCT key')
end

.sip_attribute_values_for(sip:, key:) ⇒ Object



5
6
7
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 5

def sip_attribute_values_for(sip:, key:)
  Models::AdditionalAttribute.where(sip: sip, key: key).pluck(:value)
end

.sip_default_attribute_keys_forObject



25
26
27
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 25

def sip_default_attribute_keys_for(*)
  [:publication_date]
end

Instance Method Details

#sip_attribute_key_value_pairs(sip:, keys: []) ⇒ Object



11
12
13
14
15
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 11

def sip_attribute_key_value_pairs(sip:, keys: [])
  query = Models::AdditionalAttribute.where(sip: sip).order(:sip_id, :key)
  query = query.where(key: keys) if keys.present?
  query.pluck(:key, :value)
end

#sip_attribute_keys_for(sip:) ⇒ Object



19
20
21
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 19

def sip_attribute_keys_for(sip:)
  Models::AdditionalAttribute.where(sip: sip).order(:key).pluck('DISTINCT key')
end

#sip_attribute_values_for(sip:, key:) ⇒ Object



5
6
7
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 5

def sip_attribute_values_for(sip:, key:)
  Models::AdditionalAttribute.where(sip: sip, key: key).pluck(:value)
end

#sip_default_attribute_keys_forObject



25
26
27
# File 'app/repositories/sipity/queries/additional_attribute_queries.rb', line 25

def sip_default_attribute_keys_for(*)
  [:publication_date]
end