custom-attributes 0.2.2 → 0.2.3
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
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
module ActsAsTaggableOn
|
4
|
+
class MigrationGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
desc "Generates migration for Custom Attribute models"
|
8
|
+
|
9
|
+
def self.orm
|
10
|
+
Rails::Generators.options[:rails][:orm]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) )
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.orm_has_migration?
|
18
|
+
[:active_record].include? orm
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.next_migration_number(path)
|
22
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_migration_file
|
26
|
+
if self.class.orm_has_migration?
|
27
|
+
migration_template 'migration.rb', 'db/migrate/acts_as_taggable_on_migration'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class ActsAsTaggableOnMigration < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :custom_attributes do |t|
|
4
|
+
# label
|
5
|
+
t.string :field_name
|
6
|
+
t.string :field_label
|
7
|
+
|
8
|
+
# value type
|
9
|
+
t.string :value_type
|
10
|
+
|
11
|
+
# fields for value storage
|
12
|
+
t.string :text_value
|
13
|
+
t.datetime :date_time_value
|
14
|
+
t.integer :number_value
|
15
|
+
t.float :float_value
|
16
|
+
|
17
|
+
# sorting
|
18
|
+
t.integer :position
|
19
|
+
# link to object
|
20
|
+
t.references :item, :polymorphic => true
|
21
|
+
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index :custom_attributes, :value_type
|
26
|
+
add_index :custom_attributes, [:item_id, :item_type]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.down
|
30
|
+
drop_table :custom_attributes
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: custom-attributes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 3
|
10
|
+
version: 0.2.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthijs Groen
|
@@ -42,6 +42,8 @@ files:
|
|
42
42
|
- lib/active_record/custom_attributes/custom_attribute_model.rb
|
43
43
|
- lib/custom-attributes.rb
|
44
44
|
- lib/formtastic/custom_attributes.rb
|
45
|
+
- lib/generators/acts_as_taggable_on/migration/migration_generator.rb
|
46
|
+
- lib/generators/acts_as_taggable_on/migration/templates/active_record/migration.rb
|
45
47
|
- rails/init.rb
|
46
48
|
- spec/custom_attributes/has_custom_attributes_spec.rb
|
47
49
|
- spec/database.yml
|