mdd 3.0.1 → 3.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.
@@ -70,6 +70,8 @@ module Mdwa
70
70
 
71
71
  next # nothing's changed, go to the next entity
72
72
  end
73
+
74
+ next if entity.user?
73
75
 
74
76
  # check what changed
75
77
  model_class.columns.each do |column|
@@ -78,7 +80,7 @@ module Mdwa
78
80
 
79
81
  entity_attribute = entity.attributes[column.name]
80
82
  # model attribute exists, but not in entity -> was erased
81
- if entity_attribute.nil?
83
+ if entity_attribute.nil?
82
84
  @changes << {:entity => entity, :type => 'remove_column', :column => column.name}
83
85
  # attribute exists in model and entity, but changed type
84
86
  elsif entity_attribute.type.to_sym != column.type.to_sym
@@ -69,7 +69,15 @@ module Mdwa
69
69
 
70
70
  def model_and_migration
71
71
  # model override
72
- template 'model.rb', "app/models/#{@model.space}/#{@model.singular_name}.rb"
72
+ gsub_file "app/models/#{@model.space}/#{@model.singular_name}.rb", 'ActiveRecord::Base', 'User'
73
+ inject_into_class "app/models/#{@model.space}/#{@model.singular_name}.rb", @model.model_class do
74
+ inj = []
75
+ inj << "\n\tafter_create :create_#{@model.singular_name}_permission\n"
76
+ inj << "\tdef create_#{@model.singular_name}_permission"
77
+ inj << "\t\tself.permissions.push Permission.find_by_name('#{@model.singular_name}')"
78
+ inj << "\tend"
79
+ inj.join("\n")
80
+ end
73
81
 
74
82
  # override model attributes to not allow field duplicity (causing errorss)
75
83
  @model.attributes = []
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module MDWA
3
- VERSION = "3.0.1"
3
+ VERSION = "3.0.2"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdd
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-16 00:00:00.000000000 Z
12
+ date: 2012-07-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -310,7 +310,6 @@ files:
310
310
  - lib/generators/mdwa/user/templates/controllers/ajax_controller.rb
311
311
  - lib/generators/mdwa/user/templates/controllers/controller.rb
312
312
  - lib/generators/mdwa/user/templates/migrate.rb
313
- - lib/generators/mdwa/user/templates/model.rb
314
313
  - lib/generators/mdwa/user/templates/views/update.js.erb
315
314
  - lib/generators/mdwa/user/user_generator.rb
316
315
  - lib/mdd.rb
@@ -1,11 +0,0 @@
1
- class <%= @model.klass %> < User
2
-
3
- attr_accessible <%= @model.simple_attributes.collect {|a| ":" + a.name }.join(', ') %>
4
-
5
- after_create :create_<%= @model.singular_name %>_permission
6
-
7
- def create_<%= @model.singular_name %>_permission
8
- self.permissions.push Permission.find_by_name("<%= @model.singular_name %>")
9
- end
10
-
11
- end