zendesk-features 1.0.1 → 1.0.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{features}
5
- s.version = "1.0.1"
5
+ s.version = "1.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Mick Staugaard", "Morten Primdahl"]
9
- s.date = %q{2009-06-02}
9
+ s.date = %q{2009-07-29}
10
10
  s.email = %q{mick@zendesk.com}
11
11
  s.extra_rdoc_files = [
12
12
  "README.rdoc"
@@ -28,11 +28,10 @@ Gem::Specification.new do |s|
28
28
  "test/schema.rb",
29
29
  "test/test_helper.rb"
30
30
  ]
31
- s.has_rdoc = true
32
31
  s.homepage = %q{http://github.com/zendesk/features}
33
32
  s.rdoc_options = ["--charset=UTF-8"]
34
33
  s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.1}
34
+ s.rubygems_version = %q{1.3.5}
36
35
  s.summary = %q{Features is a nice little gem for associating application features with an active record model in a Rails app}
37
36
  s.test_files = [
38
37
  "test/features_test.rb",
@@ -42,7 +41,7 @@ Gem::Specification.new do |s|
42
41
 
43
42
  if s.respond_to? :specification_version then
44
43
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
- s.specification_version = 2
44
+ s.specification_version = 3
46
45
 
47
46
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
48
47
  else
@@ -11,6 +11,12 @@ module Features
11
11
  @owner.features?(*Feature.sym_to_class(feature_name).required_features.map(&:to_sym))
12
12
  end
13
13
 
14
+ def build(*feature_names)
15
+ feature_names.each do |feature_name|
16
+ self << Feature.sym_to_class(feature_name).new
17
+ end
18
+ end
19
+
14
20
  # Define the feature query methods, given that the feature +wiffle+ is defined,
15
21
  # then the methods +account.features.wiffle?+ and +account.features.wiffle!+ will
16
22
  # be available
@@ -16,15 +16,10 @@ module Features
16
16
 
17
17
  LIST = []
18
18
 
19
- validate_on_create :unique_type
20
19
  after_create :reset_owner_association
21
20
  after_destroy :reset_owner_association
22
21
  before_destroy :destroy_dependant_features
23
22
 
24
- def unique_type
25
- errors.add(:feature, :taken) if self.class.exists?(self.class.feature_owner_key => send(self.class.feature_owner_key))
26
- end
27
-
28
23
  def available?
29
24
  feature_owner_instance.features.available?(to_sym)
30
25
  end
@@ -88,7 +83,7 @@ module Features
88
83
  send(self.class.feature_owner)
89
84
  end
90
85
  def update_owner_timestamp
91
- feature_owner_instance.update_attribute(:updated_at, Time.now)
86
+ feature_owner_instance.update_attribute(:updated_at, Time.now) if feature_owner_instance && !feature_owner_instance.new_record?
92
87
  end
93
88
 
94
89
  def reset_owner_association
@@ -116,6 +111,7 @@ module Features
116
111
  @feature_owner_sym = owner_class.name.underscore.to_sym
117
112
  belongs_to @feature_owner_sym
118
113
  validates_presence_of @feature_owner_sym
114
+ validates_uniqueness_of :type, :scope => feature_owner_key
119
115
  if owner_class.table_exists? && owner_class.column_names.include?('updated_at')
120
116
  before_create :update_owner_timestamp
121
117
  before_destroy :update_owner_timestamp
@@ -127,7 +123,7 @@ module Features
127
123
  end
128
124
 
129
125
  def self.feature_owner_key
130
- "#{@feature_owner}_id".to_sym
126
+ "#{feature_owner}_id".to_sym
131
127
  end
132
128
  end
133
129
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk-features
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mick Staugaard
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-06-02 00:00:00 -07:00
13
+ date: 2009-07-29 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
@@ -38,8 +38,9 @@ files:
38
38
  - test/fixtures/features.yml
39
39
  - test/schema.rb
40
40
  - test/test_helper.rb
41
- has_rdoc: true
41
+ has_rdoc: false
42
42
  homepage: http://github.com/zendesk/features
43
+ licenses:
43
44
  post_install_message:
44
45
  rdoc_options:
45
46
  - --charset=UTF-8
@@ -60,9 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
61
  requirements: []
61
62
 
62
63
  rubyforge_project:
63
- rubygems_version: 1.2.0
64
+ rubygems_version: 1.3.5
64
65
  signing_key:
65
- specification_version: 2
66
+ specification_version: 3
66
67
  summary: Features is a nice little gem for associating application features with an active record model in a Rails app
67
68
  test_files:
68
69
  - test/features_test.rb