hydra_attribute 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,4 +1,7 @@
1
- **0.1.1 (June 6, 2012)**
1
+ **0.1.2 (June 7, 2012)**
2
+ * eval define_hydra_attributes block in Builder scope
3
+
4
+ **0.1.1 (June 6, 2012)**
2
5
 
3
6
  **0.1.0 (June 6, 2012)** (initial release)
4
7
  * define EAV attributes
data/README.md CHANGED
@@ -65,12 +65,12 @@ rake db:migrate
65
65
  class SimpleProduct < Product
66
66
  attr_accessible :name, :title, :code, :quantity, :price, :active, :description
67
67
 
68
- define_hydra_attributes do |hydra|
69
- hydra.string :title, :code
70
- hydra.integer :quantity
71
- hydra.float :price
72
- hydra.boolean :active
73
- hydra.text :description
68
+ define_hydra_attributes do
69
+ string :title, :code
70
+ integer :quantity
71
+ float :price
72
+ boolean :active
73
+ text :description
74
74
  end
75
75
  end
76
76
  ```
@@ -10,9 +10,9 @@ end
10
10
 
11
11
  Given /^create model class "([^"]+)" as "([^"]+)" with hydra attributes:$/ do |klass, sti_class, table|
12
12
  Object.const_set klass, Class.new(Object.const_get(sti_class)) {
13
- define_hydra_attributes do |hydra|
13
+ define_hydra_attributes do
14
14
  table.hashes.each do |hash|
15
- hydra.send(hash[:type], hash[:name].to_sym)
15
+ send(hash[:type], hash[:name].to_sym)
16
16
  end
17
17
  end
18
18
  }
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/kostyantyn/Sites/github/gems/hydra_attribute
3
3
  specs:
4
- hydra_attribute (0.1.0.beta2)
4
+ hydra_attribute (0.1.2.beta1)
5
5
  activerecord (>= 3.1.0)
6
6
 
7
7
  GEM
@@ -56,5 +56,6 @@ DEPENDENCIES
56
56
  cucumber
57
57
  database_cleaner
58
58
  hydra_attribute!
59
+ rake
59
60
  rspec
60
61
  sqlite3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/kostyantyn/Sites/github/gems/hydra_attribute
3
3
  specs:
4
- hydra_attribute (0.1.0.beta2)
4
+ hydra_attribute (0.1.2.beta1)
5
5
  activerecord (>= 3.1.0)
6
6
 
7
7
  GEM
@@ -56,5 +56,6 @@ DEPENDENCIES
56
56
  cucumber
57
57
  database_cleaner
58
58
  hydra_attribute!
59
+ rake
59
60
  rspec
60
61
  sqlite3
@@ -4,8 +4,8 @@ require File.expand_path('../lib/hydra_attribute/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.author = 'Kostyantyn Stepanyuk'
6
6
  gem.email = 'kostya.stepanyuk@gmail.com'
7
- gem.summary = 'hydra_attribute allows to use EAV database structure for ActiveRecord models.'
8
- gem.description = 'hydra_attribute allows to use EAV database structure for ActiveRecord models.'
7
+ gem.summary = 'hydra_attribute is an implementation of EAV pattern for ActiveRecord models.'
8
+ gem.description = 'hydra_attribute is an implementation of EAV pattern for ActiveRecord models.'
9
9
  gem.homepage = 'https://github.com/kostyantyn/hydra_attribute'
10
10
  gem.files = `git ls-files`.split("\n")
11
11
  gem.test_files = `git ls-files -- Appraisals {spec,features,gemfiles}/*`.split("\n")
@@ -1,5 +1,5 @@
1
1
  Description:
2
- This generator generate the default initializer file.
2
+ This generator generates the default initializer file.
3
3
 
4
4
  Usage:
5
5
  rails generate hydra_attribute:install
@@ -1,7 +1,7 @@
1
1
  module HydraAttribute
2
2
  module ActiveRecord
3
- def define_hydra_attributes
4
- yield Builder.new(self)
3
+ def define_hydra_attributes(&block)
4
+ Builder.new(self).instance_eval(&block)
5
5
  end
6
6
  end
7
7
  end
@@ -25,7 +25,7 @@ module HydraAttribute
25
25
  def add_association_for_class
26
26
  assoc = config.association(@type)
27
27
  unless @klass.reflect_on_association(assoc)
28
- @klass.has_many assoc, as: :entity, class_name: config.associated_model_name(@type), autosave: true, dependent: :destroy
28
+ @klass.has_many assoc, as: :entity, class_name: config.associated_model_name(@type), autosave: true, dependent: :delete_all
29
29
  end
30
30
  end
31
31
 
@@ -1,3 +1,3 @@
1
1
  module HydraAttribute
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -4,16 +4,14 @@ describe HydraAttribute::ActiveRecord do
4
4
  let(:klass) { Class.new.extend(HydraAttribute::ActiveRecord) }
5
5
 
6
6
  describe '#define_hydra_attributes' do
7
- let(:builder) { @builder }
8
- before { klass.define_hydra_attributes { |b| @builder = b } }
9
-
10
- it 'should yield block with preconfigured current class' do
11
- builder.should be_an_instance_of(HydraAttribute::Builder)
12
- builder.klass.should be_equal(klass)
13
-
7
+ it 'should yield block in builder scope' do
8
+ klass.define_hydra_attributes do
9
+ self.class.should == HydraAttribute::Builder
10
+ end
14
11
  end
15
12
 
16
13
  it 'should include HydraAttribute::ActiveRecord::Scoping to class' do
14
+ klass.define_hydra_attributes {}
17
15
  klass.should include(HydraAttribute::ActiveRecord::Scoping)
18
16
  end
19
17
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-06 00:00:00.000000000Z
12
+ date: 2012-06-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &2152971480 !ruby/object:Gem::Requirement
16
+ requirement: &2152687640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152971480
24
+ version_requirements: *2152687640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2152971000 !ruby/object:Gem::Requirement
27
+ requirement: &2152687240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152971000
35
+ version_requirements: *2152687240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &2152970320 !ruby/object:Gem::Requirement
38
+ requirement: &2152686780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2152970320
46
+ version_requirements: *2152686780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sqlite3
49
- requirement: &2152969500 !ruby/object:Gem::Requirement
49
+ requirement: &2152686340 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2152969500
57
+ version_requirements: *2152686340
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: database_cleaner
60
- requirement: &2152969080 !ruby/object:Gem::Requirement
60
+ requirement: &2152685920 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2152969080
68
+ version_requirements: *2152685920
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: appraisal
71
- requirement: &2152968660 !ruby/object:Gem::Requirement
71
+ requirement: &2152685500 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2152968660
79
+ version_requirements: *2152685500
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rake
82
- requirement: &2152968120 !ruby/object:Gem::Requirement
82
+ requirement: &2152685080 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,8 +87,8 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2152968120
91
- description: hydra_attribute allows to use EAV database structure for ActiveRecord
90
+ version_requirements: *2152685080
91
+ description: hydra_attribute is an implementation of EAV pattern for ActiveRecord
92
92
  models.
93
93
  email: kostya.stepanyuk@gmail.com
94
94
  executables: []
@@ -175,7 +175,7 @@ rubyforge_project:
175
175
  rubygems_version: 1.8.10
176
176
  signing_key:
177
177
  specification_version: 3
178
- summary: hydra_attribute allows to use EAV database structure for ActiveRecord models.
178
+ summary: hydra_attribute is an implementation of EAV pattern for ActiveRecord models.
179
179
  test_files:
180
180
  - Appraisals
181
181
  - features/attribute_methods.feature