plant 0.2.0 → 0.3.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: 08a154178a5f74e79d298b75099d4063418de944
4
- data.tar.gz: 75f42385c8d550f8ebc857353cb3f6739325d105
3
+ metadata.gz: bba9b538452eac1f4dfaefeb3f4c7a8c1c4a991a
4
+ data.tar.gz: f04525ade799e3f18ffff45adcdd2e7153f34372
5
5
  SHA512:
6
- metadata.gz: b1d8cc8b2ed63e974c92d04e618b140641a93b7b45421957e89f8346018f8204e3b411959a82671ce5d6b3b8f3d382d579c9905cbfe8c8906707584d19dc68c2
7
- data.tar.gz: a9bea19ba2cab72e00cdfbeee0746bacab5bb6a9dedd43405c5f2c166597388611661065bd48d816be564d7ffbe98557af7d79f3a5e8fe4b1fb133d90f18550b
6
+ metadata.gz: 0bd0763eaf431fe891871e191527f83dea46ebc9478279f01cb866b1a14e4f063ae27ded0d06ff884358e56445017fe0e538f1f3611f8d84d713db1f2ade9e92
7
+ data.tar.gz: 739f7e7af8fce53bfbc50a9cf8ff670dfb27b87588cb4bb955545bd6879772447ebb03c573cf38adcbe3db3a1cabdf66039cbd735f132f78e0f876631f774a47
@@ -3,7 +3,7 @@ module Plant
3
3
  # Namespace application helper for writing to page
4
4
  module ApplicationHelper
5
5
  def get_content_for(node, user)
6
- Plant::Content.get_node_content(node,user)
6
+ Plant::Content.get_node_content(node, user)
7
7
  end
8
8
  end
9
9
  end
@@ -15,19 +15,16 @@ module Plant
15
15
  scenario = scenario.scenario if scenario.respond_to? :scenario
16
16
  specific = where(node_id: "#{node}.#{scenario}").first
17
17
  return specific.content if specific
18
- find_by!(node_id: "#{node}.main").content
18
+ find_main(node)
19
19
  end
20
20
 
21
- # Can only have one scenario-node_id combination
22
- validates_uniqueness_of :scenario, scope: :node_id
23
-
24
- before_validation :add_main
25
-
26
- private
27
-
28
- def add_main
29
- append = scenario ? scenario : 'main'
30
- self.node_id += ".#{append}" unless node_id.ends_with?(append)
21
+ def self.find_main(node)
22
+ main = find_by(node_id: "#{node}.main")
23
+ return main.content if main
24
+ find_by!(node_id: "#{node}").content
31
25
  end
26
+
27
+ # Can only have one scenario-node_id combination
28
+ validates_uniqueness_of :node_id
32
29
  end
33
30
  end
@@ -4,8 +4,6 @@ class CreatePlantContents < ActiveRecord::Migration
4
4
  create_table :plant_contents do |t|
5
5
  t.string :node_id
6
6
  t.text :content
7
- t.string :scenario
8
-
9
7
  t.timestamps null: false
10
8
  end
11
9
  end
data/lib/plant/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # Version file
2
2
  module Plant
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yule