Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added ixtlan options

  • Loading branch information...
commit f8032338835e24b9fec3097d33b7e4355a9e142b 1 parent 8c76d36
Christian Meier authored
2  Rakefile
View
@@ -9,7 +9,7 @@ require 'pathname'
require './lib/datamapper4rails/version.rb'
-Hoe.new('datamapper4rail', Datamapper4rails::VERSION) do |p|
+Hoe.new('datamapper4rail-ixtlan', Datamapper4rails::VERSION) do |p|
p.rubyforge_name = 'datamapper4rail'
p.developer('mkristian', 'm.kristian@web.de')
p.extra_deps = ['slf4r']
26 generators/rspec_dm_controller/templates/controller.rb
View
@@ -2,7 +2,11 @@ class <%= controller_class_name %>Controller < ApplicationController
# GET /<%= table_name %>
# GET /<%= table_name %>.xml
def index
+<% if options[:ixtlan] -%>
+ @<%= table_name %> = <%= class_name %>.all(@find_all_args)
+<% else -%>
@<%= table_name %> = <%= class_name %>.all()
+<% end -%>
respond_to do |format|
format.html # index.html.erb
@@ -76,8 +80,8 @@ def update
# DELETE /<%= table_name %>/1
# DELETE /<%= table_name %>/1.xml
def destroy
- <%= file_name %> = <%= class_name %>.get(params[:id])
- <%= file_name %>.destroy if <%= file_name %>
+ @<%= file_name %> = <%= class_name %>.get(params[:id])
+ @<%= file_name %>.destroy if @<%= file_name %>
respond_to do |format|
flash[:notice] = <% if options[:i18n] -%>t('<%= plural_name %>.<%= singular_name %>_deleted')<% else -%>'<%= class_name %> was successfully deleted.'<% end -%>
@@ -86,4 +90,22 @@ def destroy
format.xml { head :ok }
end
end
+
+<% if options[:ixtlan] -%>
+ private
+
+ def audit
+ if @<%= file_name %>
+ @<%= file_name %>.to_s
+ elsif @<%= table_name %>
+<% if options[:ixtlan] -%>
+ "<%= controller_class_name %>[#{@<%= table_name %>.size};#{@field}:#{@direction}]"
+<% else -%>
+ "<%= controller_class_name %>[#{@<%= table_name %>.size}]"
+<% end -%>
+ else
+ ""
+ end
+ end
+<% end -%>
end
5 generators/rspec_dm_controller/templates/controller_spec.rb
View
@@ -13,6 +13,11 @@ def user.groups
[Group.new(:name => "root")]
end
controller.send(:current_user=, user)
+<% if options[:ixtlan] -%>
+ mock_configuration = mock_model(Configuration,{})
+ Configuration.should_receive(:instance).any_number_of_times.and_return(mock_configuration)
+ mock_configuration.should_receive(:session_idle_timeout).any_number_of_times.and_return(1)
+<% end -%>
end
<% end -%>
6 generators/rspec_dm_model/templates/model.rb
View
@@ -14,4 +14,10 @@ class <%= class_name %>
timestamps :at
<% end -%>
+
+<% if options[:ixtlan] -%>
+ def to_s
+ "<%= class_name %>(#{attribute_get(:id)})"
+ end
+<% end -%>
end
Please sign in to comment.
Something went wrong with that request. Please try again.