acts_as_customized_attributes 0.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.
Files changed (57) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +73 -0
  4. data/Rakefile +26 -0
  5. data/app/models/acts_as_customized_attributes/data.rb +3 -0
  6. data/app/models/acts_as_customized_attributes/data_key.rb +3 -0
  7. data/config/routes.rb +2 -0
  8. data/lib/acts_as_customized_attributes/class_methods.rb +76 -0
  9. data/lib/acts_as_customized_attributes/compatibility.rb +5 -0
  10. data/lib/acts_as_customized_attributes/engine.rb +4 -0
  11. data/lib/acts_as_customized_attributes/instance_methods.rb +20 -0
  12. data/lib/acts_as_customized_attributes/version.rb +3 -0
  13. data/lib/acts_as_customized_attributes.rb +13 -0
  14. data/lib/tasks/acts_as_customized_attributes_tasks.rake +4 -0
  15. data/spec/dummy/Rakefile +7 -0
  16. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  17. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  18. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  19. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  20. data/spec/dummy/app/models/order.rb +5 -0
  21. data/spec/dummy/app/models/user.rb +3 -0
  22. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/spec/dummy/config/application.rb +45 -0
  24. data/spec/dummy/config/boot.rb +10 -0
  25. data/spec/dummy/config/database.example.yml +42 -0
  26. data/spec/dummy/config/database.shippable.yml +6 -0
  27. data/spec/dummy/config/database.yml +19 -0
  28. data/spec/dummy/config/environment.rb +5 -0
  29. data/spec/dummy/config/environments/development.rb +30 -0
  30. data/spec/dummy/config/environments/production.rb +60 -0
  31. data/spec/dummy/config/environments/test.rb +39 -0
  32. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  33. data/spec/dummy/config/initializers/inflections.rb +10 -0
  34. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  35. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  36. data/spec/dummy/config/initializers/session_store.rb +8 -0
  37. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  38. data/spec/dummy/config/locales/en.yml +5 -0
  39. data/spec/dummy/config/routes.rb +58 -0
  40. data/spec/dummy/config.ru +4 -0
  41. data/spec/dummy/db/migrate/20141118114902_create_users.rb +9 -0
  42. data/spec/dummy/db/migrate/20141118114941_create_user_customized_attributes.rb +9 -0
  43. data/spec/dummy/db/migrate/20141118134833_create_orders.rb +9 -0
  44. data/spec/dummy/db/migrate/20141118135027_create_order_customized_attributes.rb +9 -0
  45. data/spec/dummy/db/schema.rb +68 -0
  46. data/spec/dummy/log/development.log +92 -0
  47. data/spec/dummy/log/test.log +1067 -0
  48. data/spec/dummy/public/404.html +26 -0
  49. data/spec/dummy/public/422.html +26 -0
  50. data/spec/dummy/public/500.html +26 -0
  51. data/spec/dummy/public/favicon.ico +0 -0
  52. data/spec/dummy/script/rails +6 -0
  53. data/spec/factories/order.rb +5 -0
  54. data/spec/factories/user.rb +5 -0
  55. data/spec/models/user_spec.rb +25 -0
  56. data/spec/spec_helper.rb +41 -0
  57. metadata +225 -0
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,58 @@
1
+ Dummy::Application.routes.draw do
2
+ # The priority is based upon order of creation:
3
+ # first created -> highest priority.
4
+
5
+ # Sample of regular route:
6
+ # match 'products/:id' => 'catalog#view'
7
+ # Keep in mind you can assign values other than :controller and :action
8
+
9
+ # Sample of named route:
10
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
+ # This route can be invoked with purchase_url(:id => product.id)
12
+
13
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
14
+ # resources :products
15
+
16
+ # Sample resource route with options:
17
+ # resources :products do
18
+ # member do
19
+ # get 'short'
20
+ # post 'toggle'
21
+ # end
22
+ #
23
+ # collection do
24
+ # get 'sold'
25
+ # end
26
+ # end
27
+
28
+ # Sample resource route with sub-resources:
29
+ # resources :products do
30
+ # resources :comments, :sales
31
+ # resource :seller
32
+ # end
33
+
34
+ # Sample resource route with more complex sub-resources
35
+ # resources :products do
36
+ # resources :comments
37
+ # resources :sales do
38
+ # get 'recent', :on => :collection
39
+ # end
40
+ # end
41
+
42
+ # Sample resource route within a namespace:
43
+ # namespace :admin do
44
+ # # Directs /admin/products/* to Admin::ProductsController
45
+ # # (app/controllers/admin/products_controller.rb)
46
+ # resources :products
47
+ # end
48
+
49
+ # You can have the root of your site routed with "root"
50
+ # just remember to delete public/index.html.
51
+ # root :to => 'welcome#index'
52
+
53
+ # See how all your routes lay out with "rake routes"
54
+
55
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
56
+ # Note: This route will make all actions in every controller accessible via GET requests.
57
+ # match ':controller(/:action(/:id(.:format)))'
58
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,9 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :email
5
+ t.string :password
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateUserCustomizedAttributes < ActiveRecord::Migration
2
+ def up
3
+ User.create_customized_attributes!
4
+ end
5
+
6
+ def down
7
+ User.drop_customized_attributes!
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateOrders < ActiveRecord::Migration
2
+ def change
3
+ create_table :orders do |t|
4
+ t.belongs_to :user
5
+ t.float :amount_full
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class CreateOrderCustomizedAttributes < ActiveRecord::Migration
2
+ def up
3
+ Order.create_customized_attributes!
4
+ end
5
+
6
+ def down
7
+ Order.drop_customized_attributes!
8
+ end
9
+ end
@@ -0,0 +1,68 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 20141118135027) do
15
+
16
+ create_table "order_data", :force => true do |t|
17
+ t.integer "resource_id"
18
+ t.integer "data_key_id"
19
+ t.string "value"
20
+ t.datetime "created_at"
21
+ t.datetime "updated_at"
22
+ end
23
+
24
+ add_index "order_data", ["data_key_id"], :name => "index_order_data_on_data_key_id"
25
+
26
+ create_table "order_data_keys", :force => true do |t|
27
+ t.string "name"
28
+ t.string "title"
29
+ t.datetime "created_at"
30
+ t.datetime "updated_at"
31
+ end
32
+
33
+ add_index "order_data_keys", ["name"], :name => "index_order_data_keys_on_name"
34
+
35
+ create_table "orders", :force => true do |t|
36
+ t.integer "user_id"
37
+ t.float "amount_full"
38
+ t.datetime "created_at"
39
+ t.datetime "updated_at"
40
+ end
41
+
42
+ create_table "user_data", :force => true do |t|
43
+ t.integer "resource_id"
44
+ t.integer "data_key_id"
45
+ t.string "value"
46
+ t.datetime "created_at"
47
+ t.datetime "updated_at"
48
+ end
49
+
50
+ add_index "user_data", ["data_key_id"], :name => "index_user_data_on_data_key_id"
51
+
52
+ create_table "user_data_keys", :force => true do |t|
53
+ t.string "name"
54
+ t.string "title"
55
+ t.datetime "created_at"
56
+ t.datetime "updated_at"
57
+ end
58
+
59
+ add_index "user_data_keys", ["name"], :name => "index_user_data_keys_on_name"
60
+
61
+ create_table "users", :force => true do |t|
62
+ t.string "email"
63
+ t.string "password"
64
+ t.datetime "created_at"
65
+ t.datetime "updated_at"
66
+ end
67
+
68
+ end
@@ -0,0 +1,92 @@
1
+  (20.8ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
2
+  (43.7ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
3
+  (1.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
4
+ Migrating to CreateUsers (20141118114902)
5
+  (20.0ms) CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `email` varchar(255), `password` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
6
+  (10.0ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118114902')
7
+ Migrating to CreateUserCustomizedData (20141118114941)
8
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
9
+ Migrating to CreateUsers (20141118114902)
10
+ Migrating to CreateUserCustomizedData (20141118114941)
11
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
12
+ Migrating to CreateUsers (20141118114902)
13
+ Migrating to CreateUserCustomizedData (20141118114941)
14
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
15
+ Migrating to CreateUsers (20141118114902)
16
+ Migrating to CreateUserCustomizedData (20141118114941)
17
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
18
+ Migrating to CreateUsers (20141118114902)
19
+ Migrating to CreateUserCustomizedData (20141118114941)
20
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
21
+ Migrating to CreateUsers (20141118114902)
22
+ Migrating to CreateUserCustomizedData (20141118114941)
23
+  (17.9ms) CREATE TABLE `users_customized_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `resource_id` int(11), `resource_type` varchar(255), `key` varchar(255), `value` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
24
+  (33.7ms) CREATE INDEX `index_users_customized_data_on_key` ON `users_customized_data` (`key`)
25
+  (9.6ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118114941')
26
+  (0.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
27
+  (1.0ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
28
+ Migrating to CreateUsers (20141118114902)
29
+ Migrating to CreateUserCustomizedData (20141118114941)
30
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
31
+  (1.0ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
32
+  (0.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
33
+ Migrating to CreateUserCustomizedData (20141118114941)
34
+  (12.5ms) DROP TABLE `users_customized_data`
35
+  (8.9ms) DELETE FROM `schema_migrations` WHERE `schema_migrations`.`version` = '20141118114941'
36
+  (0.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
37
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
38
+ Migrating to CreateUsers (20141118114902)
39
+ Migrating to CreateUserCustomizedData (20141118114941)
40
+  (19.0ms) CREATE TABLE `users_customized_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `resource_id` int(11), `resource_type` varchar(255), `key` varchar(255), `value` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
41
+  (37.7ms) CREATE INDEX `index_users_customized_data_on_key` ON `users_customized_data` (`key`)
42
+  (7.9ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118114941')
43
+  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
44
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
45
+  (0.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
46
+ Migrating to CreateUserCustomizedData (20141118114941)
47
+  (7.2ms) DROP TABLE `users_customized_data`
48
+  (6.5ms) DELETE FROM `schema_migrations` WHERE `schema_migrations`.`version` = '20141118114941'
49
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
50
+  (0.9ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
51
+ Migrating to CreateUsers (20141118114902)
52
+ Migrating to CreateUserCustomizedData (20141118114941)
53
+  (21.5ms) CREATE TABLE `users_data_keys` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `data_key` varchar(255), `title` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
54
+  (33.0ms) CREATE INDEX `index_users_data_keys_on_data_key` ON `users_data_keys` (`data_key`)
55
+  (17.9ms) CREATE TABLE `users_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `resource_id` int(11), `resource_type` varchar(255), `data_key_id` int(11), `value` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
56
+  (31.9ms) CREATE INDEX `index_users_data_on_data_key_id` ON `users_data` (`data_key_id`)
57
+  (7.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118114941')
58
+  (0.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
59
+  (1.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
60
+  (0.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
61
+ Migrating to CreateUserCustomizedData (20141118114941)
62
+  (9.1ms) DROP TABLE `users_data`
63
+  (8.0ms) DELETE FROM `schema_migrations` WHERE `schema_migrations`.`version` = '20141118114941'
64
+  (0.1ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
65
+  (1.0ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
66
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
67
+ Migrating to CreateUsers (20141118114902)
68
+  (8.2ms) DROP TABLE `users`
69
+  (9.5ms) DELETE FROM `schema_migrations` WHERE `schema_migrations`.`version` = '20141118114902'
70
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
71
+  (15.4ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
72
+  (36.1ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
73
+  (1.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
74
+ Migrating to CreateUsers (20141118114902)
75
+  (17.3ms) CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `email` varchar(255), `password` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
76
+  (6.1ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118114902')
77
+ Migrating to CreateUserCustomizedAttributes (20141118114941)
78
+  (20.2ms) CREATE TABLE `user_data_keys` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `title` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
79
+  (29.1ms) CREATE INDEX `index_user_data_keys_on_name` ON `user_data_keys` (`name`)
80
+  (15.3ms) CREATE TABLE `user_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `resource_id` int(11), `data_key_id` int(11), `value` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
81
+  (32.6ms) CREATE INDEX `index_user_data_on_data_key_id` ON `user_data` (`data_key_id`)
82
+  (6.4ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118114941')
83
+ Migrating to CreateOrders (20141118134833)
84
+  (17.1ms) CREATE TABLE `orders` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `amount_full` float, `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
85
+  (10.1ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118134833')
86
+ Migrating to CreateOrderCustomizedAttributes (20141118135027)
87
+  (16.1ms) CREATE TABLE `order_data_keys` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `title` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
88
+  (38.7ms) CREATE INDEX `index_order_data_keys_on_name` ON `order_data_keys` (`name`)
89
+  (17.9ms) CREATE TABLE `order_data` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `resource_id` int(11), `data_key_id` int(11), `value` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB
90
+  (28.4ms) CREATE INDEX `index_order_data_on_data_key_id` ON `order_data` (`data_key_id`)
91
+  (9.9ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20141118135027')
92
+  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`