datts_right 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- datts_right (0.0.16)
4
+ datts_right (0.0.17)
5
5
  datts_right
6
6
  rails (>= 3.0.0)
7
7
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.17
1
+ 0.0.18
data/datts_right.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{datts_right}
8
- s.version = "0.0.17"
8
+ s.version = "0.0.18"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ramon Tayag"]
@@ -257,6 +257,12 @@ Gem::Specification.new do |s|
257
257
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
258
258
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
259
259
  s.add_development_dependency(%q<rcov>, [">= 0"])
260
+ s.add_development_dependency(%q<autotest>, [">= 0"])
261
+ s.add_development_dependency(%q<sqlite3>, [">= 0"])
262
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
263
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
264
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
265
+ s.add_development_dependency(%q<rcov>, [">= 0"])
260
266
  else
261
267
  s.add_dependency(%q<datts_right>, [">= 0"])
262
268
  s.add_dependency(%q<rails>, [">= 3.0.0"])
@@ -447,6 +453,12 @@ Gem::Specification.new do |s|
447
453
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
448
454
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
449
455
  s.add_dependency(%q<rcov>, [">= 0"])
456
+ s.add_dependency(%q<autotest>, [">= 0"])
457
+ s.add_dependency(%q<sqlite3>, [">= 0"])
458
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
459
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
460
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
461
+ s.add_dependency(%q<rcov>, [">= 0"])
450
462
  end
451
463
  else
452
464
  s.add_dependency(%q<datts_right>, [">= 0"])
@@ -638,6 +650,12 @@ Gem::Specification.new do |s|
638
650
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
639
651
  s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
640
652
  s.add_dependency(%q<rcov>, [">= 0"])
653
+ s.add_dependency(%q<autotest>, [">= 0"])
654
+ s.add_dependency(%q<sqlite3>, [">= 0"])
655
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
656
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
657
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
658
+ s.add_dependency(%q<rcov>, [">= 0"])
641
659
  end
642
660
  end
643
661
 
@@ -8,7 +8,7 @@ module DattsRight
8
8
  has_many :dynamic_attributes, :as => :attributable, :dependent => :destroy
9
9
  has_one :dynamic_attribute_definition, :as => :attribute_defineable, :dependent => :destroy
10
10
  after_save :save_dynamic_attribute_definition
11
- after_create :create_dynamic_attribute_definition, :inherit_definition
11
+ after_create :create_dynamic_attribute_definition_if_needed, :inherit_definition
12
12
  delegate :definition, :definition=, :to => :dynamic_attribute_definition
13
13
 
14
14
  # Carry out delayed actions before save
@@ -68,7 +68,7 @@ module DattsRight
68
68
  # Used when you have already existing records that have don't have definitions, and you want them to
69
69
  def self.create_definitions!
70
70
  self.all.each do |record|
71
- puts "Called create_definitions! on #{record.inspect}. Its dynamic_attribute_definition (if it has one: #{record.dynamic_attribute_definition.inspect})"
71
+ #puts "Called create_definitions! on #{record.inspect}. Its dynamic_attribute_definition (if it has one: #{record.dynamic_attribute_definition.inspect})"
72
72
  record.dynamic_attribute_definition.create if dynamic_attributes_options[:definition] && record.dynamic_attribute_definition.nil?
73
73
  end
74
74
  end
@@ -145,8 +145,14 @@ module DattsRight
145
145
  end
146
146
  end
147
147
 
148
+ def create_dynamic_attribute_definition_if_needed
149
+ if dynamic_attributes_options[:definition]
150
+ DynamicAttributeDefinition.create :attribute_defineable_id => self.id, :attribute_defineable_type => self.class.name
151
+ end
152
+ end
153
+
148
154
  def save_dynamic_attribute_definition
149
- dynamic_attribute_definition.save
155
+ dynamic_attribute_definition.save if dynamic_attribute_definition
150
156
  end
151
157
 
152
158
  def inherit_definition
@@ -453,4 +453,10 @@ describe DattsRight do
453
453
  }.should raise_error(ActiveRecord::UnknownAttributeError, "unknown attribute: body")
454
454
  end
455
455
  end
456
+
457
+ describe "on the definition" do
458
+ it "should not be created if it is not defined" do
459
+ Page.create.dynamic_attribute_definition.should be_nil
460
+ end
461
+ end
456
462
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datts_right
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 59
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 17
10
- version: 0.0.17
9
+ - 18
10
+ version: 0.0.18
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ramon Tayag
@@ -2854,6 +2854,96 @@ dependencies:
2854
2854
  name: rcov
2855
2855
  version_requirements: *id189
2856
2856
  prerelease: false
2857
+ - !ruby/object:Gem::Dependency
2858
+ type: :development
2859
+ requirement: &id190 !ruby/object:Gem::Requirement
2860
+ none: false
2861
+ requirements:
2862
+ - - ">="
2863
+ - !ruby/object:Gem::Version
2864
+ hash: 3
2865
+ segments:
2866
+ - 0
2867
+ version: "0"
2868
+ name: autotest
2869
+ version_requirements: *id190
2870
+ prerelease: false
2871
+ - !ruby/object:Gem::Dependency
2872
+ type: :development
2873
+ requirement: &id191 !ruby/object:Gem::Requirement
2874
+ none: false
2875
+ requirements:
2876
+ - - ">="
2877
+ - !ruby/object:Gem::Version
2878
+ hash: 3
2879
+ segments:
2880
+ - 0
2881
+ version: "0"
2882
+ name: sqlite3
2883
+ version_requirements: *id191
2884
+ prerelease: false
2885
+ - !ruby/object:Gem::Dependency
2886
+ type: :development
2887
+ requirement: &id192 !ruby/object:Gem::Requirement
2888
+ none: false
2889
+ requirements:
2890
+ - - ~>
2891
+ - !ruby/object:Gem::Version
2892
+ hash: 3
2893
+ segments:
2894
+ - 2
2895
+ - 3
2896
+ - 0
2897
+ version: 2.3.0
2898
+ name: rspec
2899
+ version_requirements: *id192
2900
+ prerelease: false
2901
+ - !ruby/object:Gem::Dependency
2902
+ type: :development
2903
+ requirement: &id193 !ruby/object:Gem::Requirement
2904
+ none: false
2905
+ requirements:
2906
+ - - ~>
2907
+ - !ruby/object:Gem::Version
2908
+ hash: 23
2909
+ segments:
2910
+ - 1
2911
+ - 0
2912
+ - 0
2913
+ version: 1.0.0
2914
+ name: bundler
2915
+ version_requirements: *id193
2916
+ prerelease: false
2917
+ - !ruby/object:Gem::Dependency
2918
+ type: :development
2919
+ requirement: &id194 !ruby/object:Gem::Requirement
2920
+ none: false
2921
+ requirements:
2922
+ - - ~>
2923
+ - !ruby/object:Gem::Version
2924
+ hash: 7
2925
+ segments:
2926
+ - 1
2927
+ - 5
2928
+ - 2
2929
+ version: 1.5.2
2930
+ name: jeweler
2931
+ version_requirements: *id194
2932
+ prerelease: false
2933
+ - !ruby/object:Gem::Dependency
2934
+ type: :development
2935
+ requirement: &id195 !ruby/object:Gem::Requirement
2936
+ none: false
2937
+ requirements:
2938
+ - - ">="
2939
+ - !ruby/object:Gem::Version
2940
+ hash: 3
2941
+ segments:
2942
+ - 0
2943
+ version: "0"
2944
+ name: rcov
2945
+ version_requirements: *id195
2946
+ prerelease: false
2857
2947
  description: Creates a separate table that saves all your dynamic attributes.
2858
2948
  email: ramon@tayag.net
2859
2949
  executables: []