hydra_attribute 0.4.0.rc2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ **0.4.0 (September 13, 2012)**
2
+ * Add attribute sets
3
+ * Add helper methods for attributes and attribute sets
4
+ * Remove `use_hydra_attributes` method from `ActiveRecord::Base`. Module `HydraAttribute::ActiveRecord` should be included instead
5
+
1
6
  **0.3.2 (July 31, 2012)**
2
7
  * Add `white_list` option which allows to add attribute to white list for entity during creation
3
8
 
data/README.md CHANGED
@@ -37,7 +37,7 @@ class CreateHydraAttributeTables < ActiveRecord::Migration
37
37
  end
38
38
  ```
39
39
 
40
- **or if we have already the entity table**
40
+ **or if we have the entity table already**
41
41
 
42
42
  ```ruby
43
43
  class CreateHydraAttributeTables < ActiveRecord::Migration
@@ -59,14 +59,7 @@ rails generate model Product type:string name:string --migration=false
59
59
  rake db:migrate
60
60
  ```
61
61
 
62
- and add `use_hydra_attributes` to Product class
63
- ```ruby
64
- class Product < ActiveRecord::Base
65
- use_hydra_attributes
66
- end
67
- ```
68
-
69
- **Starting from version 0.4.0 `use_hydra_attributes` method will be removed.**
62
+ and include `HydraAttribute::ActiveRecord` to Product class
70
63
  ```ruby
71
64
  class Product < ActiveRecord::Base
72
65
  include HydraAttribute::ActiveRecord
@@ -81,10 +74,10 @@ Product.hydra_attributes.create(name: 'total', backend_type: 'integer', default_
81
74
  ```
82
75
 
83
76
  Creating method accepts the following options:
84
- * **name**. The **required** parameter. Allowed any string.
85
- * **backend_type**. The **required** parameter. Allowed one of the following strings: `string`, `text`, `integer`, `float`, `boolean` and `datetime`.
86
- * **default_value**. The **optional** parameter. Allowed any value. By default is `nil`.
87
- * **white_list**. The **optional** parameter. Should be `true` or `flase`. By defauls is `false`. if pass `white_list: true` this attribute will be added to white list and will be allowed for mass-assignment. This parameter is in black list for creation by default so if you want to pass it, you have to pass the role `as: :admin` too.
77
+ * **name**. The **required** parameter. Any string is allowed.
78
+ * **backend_type**. The **required** parameter. One of the following strings is allowed: `string`, `text`, `integer`, `float`, `boolean` and `datetime`.
79
+ * **default_value**. The **optional** parameter. Any value is allowed. `nil` is default.
80
+ * **white_list**. The **optional** parameter. Should be `true` or `flase`. `false` is default. If `white_list: true` is passed, this attribute will be added to white list and will be allowed for mass-assignment. This parameter is in black list for creation by default so if you want to pass it, you have to pass the role `as: :admin` too.
88
81
 
89
82
  ```ruby
90
83
  Product.hydra_attributes.create({name: 'title', backend_type: 'string', white_list: true}, as: :admin)
@@ -108,7 +101,7 @@ Product.create(title: 'car', price: 2.50)
108
101
  ```
109
102
 
110
103
  ### Create hydra set
111
- **Hydra set** allows set unique attribute list for each entity.
104
+ **Hydra set** allows to set the unique attribute list for each entity.
112
105
 
113
106
  ```ruby
114
107
  hydra_set = Product.hydra_sets.create(name: 'Default')
@@ -119,7 +112,7 @@ Product.create(color: 'black', title: 'ipod', price: 49.95, total: 5) do |produc
119
112
  end
120
113
  #<Product id: 5, hydra_set_id: 1, created_at: ..., updated_at: ..., color: "black", title: "ipod", price: 49.95>
121
114
  ```
122
- **Notice:** the `total` attribute was skipped because it doesn't exist in hydra set.
115
+ **Notice:** the `total` attribute has been skipped because it doesn't exist in hydra set.
123
116
 
124
117
  ### Obtain data
125
118
  ```ruby
@@ -131,8 +124,7 @@ Product.where(color: 'green', price: nil)
131
124
  #<Product id: 3, hydra_set_id: nil, created_at: ..., updated_at: ..., color: "green", title: "book", price: 0.0, total: 2>
132
125
  # ]
133
126
  ```
134
- **Notice**: the attribute `price` was added in runtime and records that were created before have not this attribute
135
- so they matched this condition `where(price: nil)`
127
+ **Notice**: the attribute `price` has been added in runtime. Records that had been created before this attribute don't have it therefore they satisfy the following condition: `where(price: nil)`
136
128
 
137
129
  ### Order data
138
130
  ```ruby
@@ -153,7 +145,7 @@ Product.select([:color, :title])
153
145
  #<Product id: 5, hydra_set_id: 1, color: "black", title: "ipod">
154
146
  # ]
155
147
  ```
156
- **Notice:** `id` and `hydra_set_id` attributes are forced added because they are important for correct work.
148
+ **Notice:** `id` and `hydra_set_id` attributes are forcibly added because they are important for correct work.
157
149
 
158
150
  ### Group by attribute
159
151
  ```ruby
@@ -168,11 +160,11 @@ Product.group(:color).count
168
160
  * [Query methods](https://github.com/kostyantyn/hydra_attribute/wiki/Query-methods)
169
161
  * [Database schema](https://github.com/kostyantyn/hydra_attribute/wiki/Database-schema)
170
162
  * [Helper methods](https://github.com/kostyantyn/hydra_attribute/wiki/Helper-methods)
163
+ * [Migrate from 0.3.2 to 0.4.0](https://github.com/kostyantyn/hydra_attribute/wiki/Migrate-from-0.3.2-to-0.4.0)
171
164
 
172
165
  ## Notice
173
166
 
174
- The each new minor version doesn't guarantee back compatibility with previous one
175
- until the first major version will be released.
167
+ The each new minor version doesn't guarantee back compatibility with previous one until the first major version is released.
176
168
 
177
169
  ## Contributing
178
170
 
@@ -1,3 +1,3 @@
1
1
  module HydraAttribute
2
- VERSION = '0.4.0.rc2'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.rc2
5
- prerelease: 6
4
+ version: 0.4.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kostyantyn Stepanyuk
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-11 00:00:00.000000000 Z
12
+ date: 2012-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -217,9 +217,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
217
  required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  none: false
219
219
  requirements:
220
- - - ! '>'
220
+ - - ! '>='
221
221
  - !ruby/object:Gem::Version
222
- version: 1.3.1
222
+ version: '0'
223
+ segments:
224
+ - 0
225
+ hash: -1684889592311729317
223
226
  requirements: []
224
227
  rubyforge_project:
225
228
  rubygems_version: 1.8.24