ish_models 0.0.33.130 → 0.0.33.131

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gameui/map.rb +15 -3
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c34bbd347229cb392198bb194abc4c7d2902cb478aaac34b43b89c2014ab2d3
4
- data.tar.gz: 83c55591061a4ed85905e50f3aaf6fdcae9eed57d25fb4f0f36dd1cbe4d16bbe
3
+ metadata.gz: 6af77beacdc645fcf83ca862c625d2f689279acfe94cc40cc83527f4836578ed
4
+ data.tar.gz: 5860e90c3029f55d92ab8ff703e21fb5fe2d9bc1d355c68fe1e06be3cc8788c3
5
5
  SHA512:
6
- metadata.gz: a2e9dc8ad1cd2f1236963b23d8c957c586e9b6736c8477001e393d4cff2fe9033c420752a5ce73e0ff3b18fe8881c647aa15ca447a9b899f3e3fd062aacb588b
7
- data.tar.gz: e4337aed790fc7190cf0341dc158443d459b4aa0b85580594971362d38bef285fa8a6b9cae97e175a0d5f344964bc01a84778c34a042bb67bc364bde586f886e
6
+ metadata.gz: e88f2506f075b91fd496ce353358123486f9c968abb9e8837e89ef864846b2f054615732222ed4156578c012ab612df31b42d80219c14957f8167c48ad40d386
7
+ data.tar.gz: f0482b89daa1a5c15569a780ab80f74f07a7504b08cdd13b8844ef4a9a03b0a3927b7e4b5c300e6f19468b6c2f1006e961f041b8eb174a798850faf59593eedf
data/lib/gameui/map.rb CHANGED
@@ -8,10 +8,12 @@ class ::Gameui::Map
8
8
 
9
9
  field :slug
10
10
  validates :slug, uniqueness: true, presence: true
11
+
11
12
  field :parent_slug
12
- def name
13
- slug
14
- end
13
+ belongs_to :parent, class_name: '::Gameui::Map', inverse_of: :childs, optional: true
14
+ has_many :childs, class_name: '::Gameui::Map', inverse_of: :parent
15
+
16
+ field :name
15
17
 
16
18
  field :w, type: Integer
17
19
  validates :w, presence: true
@@ -35,4 +37,14 @@ class ::Gameui::Map
35
37
  [['', nil]] + out.map { |item| [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ] }
36
38
  end
37
39
 
40
+ def breadcrumbs
41
+ out = [{ name: self.name, slug: self.slug, link: false }]
42
+ p = self.parent
43
+ while p
44
+ out.push({ name: p.name, slug: p.slug })
45
+ p = p.parent
46
+ end
47
+ out.reverse
48
+ end
49
+
38
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ish_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33.130
4
+ version: 0.0.33.131
5
5
  platform: ruby
6
6
  authors:
7
7
  - piousbox