apidae 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e5d13058f65857b20c5eb5ebcb31933047d458d
4
- data.tar.gz: 57c158bf11ea28f28c25094e2e2b732289cd1b47
3
+ metadata.gz: 765dd17ae6901f726e634a675934148a79715022
4
+ data.tar.gz: bab182d1cc1367ed70b10dfda1bb1d3a08f0d47c
5
5
  SHA512:
6
- metadata.gz: '039e3d10fa484d795ad731c1a178b567f7c793b2a339ea835370f0a3c59318734ecb5bc9cd818073da9d4c16cdaf03d9d833f83c507d8589f39fe41d56c32657'
7
- data.tar.gz: 188194787706a94cf7b04854bdd92266095ee95607b24a764ad2ccadda0fec50f076bb9d0631b7bb3454c02c80c74334bb5f313832d10ac012b86ec4ad3c3e23
6
+ metadata.gz: a019141cef8e85dc8806cd73c31dfbc02e5f95758c9be26825a7c8b647a4cb99ff2fd41af12723f8c867e9b52095d583ee195011dd5d8d2cf2de2c6d1775f5d1
7
+ data.tar.gz: 6695e5409d28e870ee3096db3737e88f3db3cc701ec5362860b8eab60c65ba45678ff20e6dbc780a9dc6db1c478a2c58baaf24d2a3eb1c6eff088738c52dde77
@@ -25,30 +25,38 @@ module Apidae
25
25
  store_accessor :tags_data, :promo, :internal, :linked
26
26
  store_accessor :version_data, :versioned_fields
27
27
 
28
- LOCALIZED_FIELDS.each do |f|
29
- alias_method :"#{f}_hash", :"#{f}"
30
- alias_method :"#{f}_hash=", :"#{f}="
31
-
32
- define_method "#{f}=" do |val|
33
- ref_obj = (@obj_version == DEFAULT_VERSION || @obj_version.nil?) ? self : in_version(@obj_version)
34
- field_hash = ref_obj.send(:"#{f}_hash") || {}
35
- ref_obj.send(:"#{f}_hash=", field_hash.merge(@locale => val))
28
+ ALL_FIELDS.each do |f|
29
+ alias_method :"get_#{f}", :"#{f}"
30
+ alias_method :"set_#{f}", :"#{f}="
31
+
32
+ if LOCALIZED_FIELDS.include?(f)
33
+ define_method "#{f}=" do |val|
34
+ ref_obj = (@obj_version == DEFAULT_VERSION || @obj_version.nil?) ? self : in_version(@obj_version)
35
+ current_val = ref_obj.send(:"get_#{f}") || {}
36
+ ref_obj.send(:"set_#{f}", current_val.merge(@locale => val))
37
+ end
38
+ else
39
+ define_method "#{f}=" do |val|
40
+ ref_obj = (@obj_version == DEFAULT_VERSION || @obj_version.nil?) ? self : in_version(@obj_version)
41
+ ref_obj.send(:"set_#{f}", val)
42
+ end
36
43
  end
37
44
 
38
45
  define_method f do
39
- field_hash = self.send(:"#{f}_hash") || {}
46
+ default_value = LOCALIZED_FIELDS.include?(f) ? {} : nil
47
+ field_val = self.send(:"get_#{f}") || default_value
40
48
  unless @obj_version == DEFAULT_VERSION
41
49
  versioned_obj = in_version(@obj_version)
42
50
  if versioned_obj
43
- versioned_hash = versioned_obj.send(:"#{f}_hash") || {}
51
+ versioned_value = versioned_obj.send(:"get_#{f}") || default_value
44
52
  if versioned_obj.versioned_fields.include?(f.to_s)
45
- field_hash = versioned_hash
46
- else
47
- field_hash.deep_merge!(versioned_hash)
53
+ field_val = versioned_value
54
+ elsif field_val.respond_to?('deep_merge!')
55
+ field_val.deep_merge!(versioned_value)
48
56
  end
49
57
  end
50
58
  end
51
- field_hash[@locale] || field_hash[DEFAULT_LOCALE]
59
+ LOCALIZED_FIELDS.include?(f) ? (field_val[@locale] || field_val[DEFAULT_LOCALE]) : field_val
52
60
  end
53
61
  end
54
62
 
@@ -26,4 +26,6 @@ module Apidae
26
26
 
27
27
  LOCALIZED_FIELDS = [:title, :short_desc, :long_desc, :pictures, :attachments, :openings_desc, :rates_desc,
28
28
  :includes, :excludes, :extra, :booking_desc]
29
+ ALL_FIELDS = LOCALIZED_FIELDS + [:theme_desc, :private_desc, :capacity, :telephone, :email, :website, :services,
30
+ :equipments, :comfort, :activities, :promo, :internal, :linked]
29
31
  end
@@ -1,5 +1,6 @@
1
1
  class MigrateLocalizedApidaeObjFields < ActiveRecord::Migration[5.2]
2
2
  def change
3
+ # Todo
3
4
  Apidae::Obj.all.each do |o|
4
5
  o.short_desc_hash = {'fr' => o.description_data['short_desc']} unless (o.description_data.blank? || !o.description_data.has_key?('short_desc') || o.description_data['short_desc'].is_a?(Hash))
5
6
  o.long_desc_hash = {'fr' => o.description_data['long_desc']} unless (o.description_data.blank? || !o.description_data.has_key?('long_desc') || o.description_data['long_desc'].is_a?(Hash))
@@ -1,3 +1,3 @@
1
1
  module Apidae
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -550,7 +550,7 @@
550
550
  "ordre" : 170
551
551
  }
552
552
  } ],
553
- "tailleGroupeMax" : 72
553
+ "tailleGroupeMax" : 64
554
554
  },
555
555
  "ouverture" : {
556
556
  "periodeEnClair" : {
@@ -1242,7 +1242,7 @@
1242
1242
  },
1243
1243
  "aspects" : [ {
1244
1244
  "aspect" : "GROUPES",
1245
- "champsAspect" : [ "illustrations", "descriptionTarif.indicationTarif", "descriptionTarif.periodes", "descriptionTarif.tarifsEnClairAutomatique", "ouverture.periodeEnClair", "descriptionTarif.conditions.gratuitPourLesMoinsDe", "descriptionTarif.complement", "multimedias", "presentation.descriptifDetaille", "informations.moyensCommunication", "descriptionTarif.tarifsEnClair", "prestations.tailleGroupeMax", "ouverture.periodeEnClairAutomatique", "presentation.descriptifCourt", "reservation.complement", "ouverture.periodesOuvertures" ],
1245
+ "champsAspect" : [ "illustrations", "descriptionTarif.indicationTarif", "descriptionTarif.periodes", "descriptionTarif.tarifsEnClairAutomatique", "ouverture.periodeEnClair", "descriptionTarif.conditions.gratuitPourLesMoinsDe", "descriptionTarif.complement", "multimedias", "presentation.descriptifDetaille", "informations.moyensCommunication", "descriptionTarif.tarifsEnClair", "prestations.tailleGroupeMax", "prestations.equipements", "ouverture.periodeEnClairAutomatique", "presentation.descriptifCourt", "reservation.complement", "ouverture.periodesOuvertures" ],
1246
1246
  "informations" : {
1247
1247
  "moyensCommunication" : [ {
1248
1248
  "identifiant" : 72276483,
@@ -1288,8 +1288,20 @@
1288
1288
  }
1289
1289
  },
1290
1290
  "prestations" : {
1291
- "tailleGroupeMax" : 72
1292
- },
1291
+ "tailleGroupeMax" : 72,
1292
+ "equipements" : [ {
1293
+ "elementReferenceType" : "PrestationEquipement",
1294
+ "id" : 613,
1295
+ "libelleFr" : "Aire de pique-nique",
1296
+ "ordre" : 30,
1297
+ "familleCritere" : {
1298
+ "elementReferenceType" : "FamilleCritere",
1299
+ "id" : 122,
1300
+ "libelleFr" : "Equipements de loisirs",
1301
+ "ordre" : 51
1302
+ }
1303
+ }
1304
+ ] },
1293
1305
  "ouverture" : {
1294
1306
  "periodeEnClair" : {
1295
1307
  "libelleFr" : "Du 01/05 au 31/10.\nÀ partir de 10h30, uniquement sur réservation.\n\nSous réserve de conditions météo favorables."