Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added ixtlan options

  • Loading branch information...
commit f8032338835e24b9fec3097d33b7e4355a9e142b 1 parent 8c76d36
Christian Meier authored
2  Rakefile
@@ -9,7 +9,7 @@ require 'pathname'
9 9
 
10 10
 require './lib/datamapper4rails/version.rb'
11 11
 
12  
-Hoe.new('datamapper4rail', Datamapper4rails::VERSION) do |p|
  12
+Hoe.new('datamapper4rail-ixtlan', Datamapper4rails::VERSION) do |p|
13 13
   p.rubyforge_name = 'datamapper4rail'
14 14
   p.developer('mkristian', 'm.kristian@web.de')
15 15
   p.extra_deps = ['slf4r']
26  generators/rspec_dm_controller/templates/controller.rb
@@ -2,7 +2,11 @@ class <%= controller_class_name %>Controller < ApplicationController
2 2
   # GET /<%= table_name %>
3 3
   # GET /<%= table_name %>.xml
4 4
   def index
  5
+<% if options[:ixtlan] -%>
  6
+    @<%= table_name %> = <%= class_name %>.all(@find_all_args)
  7
+<% else -%>
5 8
     @<%= table_name %> = <%= class_name %>.all()
  9
+<% end -%>
6 10
 
7 11
     respond_to do |format|
8 12
       format.html # index.html.erb
@@ -76,8 +80,8 @@ def update
76 80
   # DELETE /<%= table_name %>/1
77 81
   # DELETE /<%= table_name %>/1.xml
78 82
   def destroy
79  
-    <%= file_name %> = <%= class_name %>.get(params[:id])
80  
-    <%= file_name %>.destroy if <%= file_name %>
  83
+    @<%= file_name %> = <%= class_name %>.get(params[:id])
  84
+    @<%= file_name %>.destroy if @<%= file_name %>
81 85
 
82 86
     respond_to do |format|
83 87
       flash[:notice] = <% if options[:i18n] -%>t('<%= plural_name %>.<%= singular_name %>_deleted')<% else -%>'<%= class_name %> was successfully deleted.'<% end -%>
@@ -86,4 +90,22 @@ def destroy
86 90
       format.xml  { head :ok }
87 91
     end
88 92
   end
  93
+
  94
+<% if options[:ixtlan] -%>
  95
+  private
  96
+
  97
+  def audit
  98
+    if @<%= file_name %>
  99
+      @<%= file_name %>.to_s
  100
+    elsif @<%= table_name %>
  101
+<% if options[:ixtlan] -%>
  102
+      "<%= controller_class_name %>[#{@<%= table_name %>.size};#{@field}:#{@direction}]"
  103
+<% else -%>
  104
+      "<%= controller_class_name %>[#{@<%= table_name %>.size}]"
  105
+<% end -%>
  106
+    else
  107
+      ""
  108
+    end
  109
+  end
  110
+<% end -%>
89 111
 end
5  generators/rspec_dm_controller/templates/controller_spec.rb
@@ -13,6 +13,11 @@ def user.groups
13 13
       [Group.new(:name => "root")]
14 14
     end
15 15
     controller.send(:current_user=, user)
  16
+<% if options[:ixtlan] -%>
  17
+    mock_configuration = mock_model(Configuration,{})
  18
+    Configuration.should_receive(:instance).any_number_of_times.and_return(mock_configuration)
  19
+    mock_configuration.should_receive(:session_idle_timeout).any_number_of_times.and_return(1)
  20
+<% end -%>
16 21
   end
17 22
 <% end -%>
18 23
 
6  generators/rspec_dm_model/templates/model.rb
@@ -14,4 +14,10 @@ class <%= class_name %>
14 14
   timestamps :at
15 15
 
16 16
 <% end -%>
  17
+
  18
+<% if options[:ixtlan] -%>
  19
+   def to_s
  20
+     "<%= class_name %>(#{attribute_get(:id)})"
  21
+   end
  22
+<% end -%>
17 23
 end

0 notes on commit f803233

Please sign in to comment.
Something went wrong with that request. Please try again.