effective_developer 0.0.9 → 0.0.10
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.
- checksums.yaml +4 -4
- data/app/models/effective/code_writer.rb +16 -1
- data/lib/effective_developer/version.rb +1 -1
- data/lib/generators/effective/datatable_generator.rb +2 -2
- data/lib/generators/effective/helpers.rb +14 -7
- data/lib/generators/effective/menu_generator.rb +1 -1
- data/lib/generators/effective/migration_generator.rb +49 -4
- data/lib/generators/effective/scaffold_controller_generator.rb +11 -3
- data/lib/generators/effective/scaffold_generator.rb +8 -0
- data/lib/scaffolds/controllers/controller.rb +19 -13
- data/lib/scaffolds/datatables/datatable.rb +8 -12
- data/lib/scaffolds/forms/_form.html.haml +4 -0
- data/lib/scaffolds/models/model.rb +2 -0
- data/lib/scaffolds/views/edit.html.haml +1 -1
- data/lib/scaffolds/views/new.html.haml +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 5c9d245ef9985403865d0ff86827272eddb8451a
         | 
| 4 | 
            +
              data.tar.gz: 3da5a891679cd2c3abbc30a4feb9a9a3e68f080d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 960474bc91e9b1ffcfed1daae6db4a2ff64fb54ded9e35574155e9c3e92ab22df7b6e6a8469d622410f71f9a385c102cbfa68d565f1531c57cd536d27df406c9
         | 
| 7 | 
            +
              data.tar.gz: cd513a9ee141d261824b2cd536c230cc795f3286d4b1348484c3ed076acb130dd5f05e2bcaed3f9f9ddbd8f3341e57c24c922eb4338a93575c20442bc78661b5
         | 
| @@ -149,7 +149,7 @@ module Effective | |
| 149 149 | 
             
                  retval
         | 
| 150 150 | 
             
                end
         | 
| 151 151 |  | 
| 152 | 
            -
                # Returns an array of indexes for each line where the passed block  | 
| 152 | 
            +
                # Returns an array of indexes for each line where the passed block returns true
         | 
| 153 153 | 
             
                def all(from: @from.last, to: @to.last, &block)
         | 
| 154 154 | 
             
                  retval = []
         | 
| 155 155 |  | 
| @@ -163,6 +163,21 @@ module Effective | |
| 163 163 | 
             
                end
         | 
| 164 164 | 
             
                alias_method :select, :all
         | 
| 165 165 |  | 
| 166 | 
            +
                # Yields each line to a block and returns an array of the results
         | 
| 167 | 
            +
                def map(from: @from.last, to: @to.last, indexes: [], &block)
         | 
| 168 | 
            +
                  retval = []
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                  each_with_depth do |line, depth, index|
         | 
| 171 | 
            +
                    next if index < (from || 0)
         | 
| 172 | 
            +
                    next unless indexes.blank? || indexes.include?(index)
         | 
| 173 | 
            +
             | 
| 174 | 
            +
                    retval << block.call(line, depth, index)
         | 
| 175 | 
            +
                    break if to == index
         | 
| 176 | 
            +
                  end
         | 
| 177 | 
            +
             | 
| 178 | 
            +
                  retval
         | 
| 179 | 
            +
                end
         | 
| 180 | 
            +
             | 
| 166 181 | 
             
                def depth_at(line_index)
         | 
| 167 182 | 
             
                  if filename.end_with?('.haml')
         | 
| 168 183 | 
             
                    return (lines[line_index].length - lines[line_index].lstrip.length) / indent.length
         | 
| @@ -13,7 +13,7 @@ module Effective | |
| 13 13 |  | 
| 14 14 | 
             
                  source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)
         | 
| 15 15 |  | 
| 16 | 
            -
                  desc 'Creates an Effective::Datatable in your app/ | 
| 16 | 
            +
                  desc 'Creates an Effective::Datatable in your app/datatables folder.'
         | 
| 17 17 |  | 
| 18 18 | 
             
                  argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]'
         | 
| 19 19 |  | 
| @@ -30,7 +30,7 @@ module Effective | |
| 30 30 | 
             
                  end
         | 
| 31 31 |  | 
| 32 32 | 
             
                  def create_datatable
         | 
| 33 | 
            -
                    template 'datatables/datatable.rb', File.join('app/ | 
| 33 | 
            +
                    template 'datatables/datatable.rb', File.join('app/datatables', namespace_path, "#{plural_name}_datatable.rb")
         | 
| 34 34 | 
             
                  end
         | 
| 35 35 |  | 
| 36 36 | 
             
                end
         | 
| @@ -36,7 +36,7 @@ module Effective | |
| 36 36 | 
             
                    invoked_attributes.present? ? (['--attributes'] + invoked_attributes) : []
         | 
| 37 37 | 
             
                  end
         | 
| 38 38 |  | 
| 39 | 
            -
                  def klass_attributes
         | 
| 39 | 
            +
                  def klass_attributes(verbose: true)
         | 
| 40 40 | 
             
                    klass = class_name.safe_constantize
         | 
| 41 41 | 
             
                    return [] unless klass
         | 
| 42 42 |  | 
| @@ -54,12 +54,19 @@ module Effective | |
| 54 54 | 
             
                    begin
         | 
| 55 55 | 
             
                      attributes = klass.new().attributes
         | 
| 56 56 | 
             
                    rescue => e
         | 
| 57 | 
            -
                      puts "Unable to call #{class_name}.new().attributes. Continuing with empty attributes."
         | 
| 57 | 
            +
                      puts "Unable to call #{class_name}.new().attributes. Continuing with empty attributes." if verbose
         | 
| 58 58 | 
             
                      return []
         | 
| 59 59 | 
             
                    end
         | 
| 60 60 |  | 
| 61 | 
            -
                     | 
| 62 | 
            -
             | 
| 61 | 
            +
                    attribute_names = attributes.keys - [klass.primary_key, 'created_at', 'updated_at']
         | 
| 62 | 
            +
                    attribute_names -= ['site_id'] if klass.respond_to?(:is_site_specific)
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                    attribute_names.map do |attr|
         | 
| 65 | 
            +
                      if klass.respond_to?(:column_for_attribute) # Rails 4+
         | 
| 66 | 
            +
                        "#{attr}:#{klass.column_for_attribute(attr).try(:type) || 'string'}"
         | 
| 67 | 
            +
                      else
         | 
| 68 | 
            +
                        "#{attr}:#{klass.columns_hash[attr].try(:type) || 'string'}"
         | 
| 69 | 
            +
                      end
         | 
| 63 70 | 
             
                    end
         | 
| 64 71 | 
             
                  end
         | 
| 65 72 |  | 
| @@ -94,11 +101,11 @@ module Effective | |
| 94 101 | 
             
                  end
         | 
| 95 102 |  | 
| 96 103 | 
             
                  def index_path
         | 
| 97 | 
            -
                    [namespace_path.underscore.presence, plural_name].compact.join('_') | 
| 104 | 
            +
                    [namespace_path.underscore.presence, plural_name, 'path'].compact.join('_')
         | 
| 98 105 | 
             
                  end
         | 
| 99 106 |  | 
| 100 107 | 
             
                  def new_path
         | 
| 101 | 
            -
                    ['new', namespace_path.underscore.presence, singular_name].compact.join('_') | 
| 108 | 
            +
                    ['new', namespace_path.underscore.presence, singular_name, 'path'].compact.join('_')
         | 
| 102 109 | 
             
                  end
         | 
| 103 110 |  | 
| 104 111 | 
             
                  def edit_path
         | 
| @@ -106,7 +113,7 @@ module Effective | |
| 106 113 | 
             
                  end
         | 
| 107 114 |  | 
| 108 115 | 
             
                  def show_path
         | 
| 109 | 
            -
                    [namespace_path.underscore.presence, singular_name | 
| 116 | 
            +
                    [namespace_path.underscore.presence, singular_name, 'path', "(@#{singular_name})"].compact.join('_')
         | 
| 110 117 | 
             
                  end
         | 
| 111 118 |  | 
| 112 119 | 
             
                end
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # rails generate effective:migration NAME [field[:type] field[:type]] [options]
         | 
| 2 2 |  | 
| 3 | 
            -
            # TODO -  | 
| 3 | 
            +
            # TODO - add default options
         | 
| 4 4 |  | 
| 5 5 | 
             
            # Generates a create_* migration
         | 
| 6 6 | 
             
            # rails generate effective:migration Thing
         | 
| @@ -22,11 +22,56 @@ module Effective | |
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| 24 24 | 
             
                  def create_migration
         | 
| 25 | 
            -
                     | 
| 25 | 
            +
                    if invoked_attributes.present?
         | 
| 26 | 
            +
                      Rails::Generators.invoke('migration', ["create_#{plural_name}"] + (invoked_attributes | timestamps))
         | 
| 27 | 
            +
                    elsif klass_attributes(verbose: false).present?
         | 
| 28 | 
            +
                      raise 'klass_attributes already exist.  We cant migrate (yet). Exiting.'
         | 
| 29 | 
            +
                    elsif written_attributes.present?
         | 
| 30 | 
            +
                      Rails::Generators.invoke('migration', ["create_#{plural_name}"] + (written_attributes | timestamps))
         | 
| 31 | 
            +
                    else
         | 
| 32 | 
            +
                      raise 'You need to specify some attributes or have a model file present'
         | 
| 33 | 
            +
                    end
         | 
| 26 34 | 
             
                  end
         | 
| 27 35 |  | 
| 28 | 
            -
                   | 
| 29 | 
            -
             | 
| 36 | 
            +
                  protected
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  # Written attributes include all belong_tos, as well as
         | 
| 39 | 
            +
                  # any Attributes comments as per our custom 'Attributes' comment block contained in the model file
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  # Attributes
         | 
| 42 | 
            +
                  # name        :string
         | 
| 43 | 
            +
                  # description :text
         | 
| 44 | 
            +
                  #
         | 
| 45 | 
            +
                  # another :string
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                  def written_attributes
         | 
| 48 | 
            +
                    @written_attributes ||= (
         | 
| 49 | 
            +
                      attributes = []
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                      Effective::CodeWriter.new(File.join('app/models', class_path, "#{file_name}.rb")) do |w|
         | 
| 52 | 
            +
                        # belong_tos
         | 
| 53 | 
            +
                        references = w.select { |line| line.start_with?('belongs_to '.freeze) }
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                        if references.present?
         | 
| 56 | 
            +
                          attributes += w.map(indexes: references) { |line| [[line.scan(/belongs_to\s+:(\w+)/).flatten.first, 'references']] }
         | 
| 57 | 
            +
                        end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                        # Attributes
         | 
| 60 | 
            +
                        first = w.find { |line| line == '# Attributes' }
         | 
| 61 | 
            +
                        break unless first
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                        last = w.find(from: first) { |line| line.start_with?('#') == false && line.length > 0 }
         | 
| 64 | 
            +
                        break unless last
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                        attributes += w.map(from: first+1, to: last-1) { |line| line.scan(/^\W+(\w+)\W+:(\w+)/).presence }
         | 
| 67 | 
            +
                      end
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                      attributes.flatten(1).compact.map { |attribute| attribute.join(':') }
         | 
| 70 | 
            +
                    )
         | 
| 71 | 
            +
                  end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                  def timestamps
         | 
| 74 | 
            +
                    ['created_at:datetime', 'updated_at:datetime']
         | 
| 30 75 | 
             
                  end
         | 
| 31 76 |  | 
| 32 77 | 
             
                end
         | 
| @@ -13,10 +13,10 @@ module Effective | |
| 13 13 |  | 
| 14 14 | 
             
                  source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)
         | 
| 15 15 |  | 
| 16 | 
            -
                  desc 'Creates an Effective Scaffold'
         | 
| 16 | 
            +
                  desc 'Creates an Effective Scaffold based on an existing model'
         | 
| 17 17 |  | 
| 18 | 
            -
                  argument : | 
| 19 | 
            -
                  class_option : | 
| 18 | 
            +
                  argument :actions, type: :array, default: ['crud'], banner: 'action action'
         | 
| 19 | 
            +
                  class_option :attributes, type: :array, default: [], desc: 'Included permitted params, otherwise read from model'
         | 
| 20 20 |  | 
| 21 21 | 
             
                  def invoke_controller
         | 
| 22 22 | 
             
                    Rails::Generators.invoke('effective:controller', [name] + invoked_actions + invoked_attributes_args)
         | 
| @@ -35,6 +35,10 @@ module Effective | |
| 35 35 | 
             
                  end
         | 
| 36 36 |  | 
| 37 37 | 
             
                  def invoke_datatable
         | 
| 38 | 
            +
                    unless invoked_actions.include?('index')
         | 
| 39 | 
            +
                      say_status(:skipped, :datatable, :yellow) and return
         | 
| 40 | 
            +
                    end
         | 
| 41 | 
            +
             | 
| 38 42 | 
             
                    Rails::Generators.invoke('effective:datatable', [name] + invoked_attributes)
         | 
| 39 43 | 
             
                  end
         | 
| 40 44 |  | 
| @@ -43,6 +47,10 @@ module Effective | |
| 43 47 | 
             
                  end
         | 
| 44 48 |  | 
| 45 49 | 
             
                  def invoke_form
         | 
| 50 | 
            +
                    unless invoked_actions.include?('new') || invoked_actions.include?('edit')
         | 
| 51 | 
            +
                      say_status(:skipped, :form, :yellow) and return
         | 
| 52 | 
            +
                    end
         | 
| 53 | 
            +
             | 
| 46 54 | 
             
                    Rails::Generators.invoke('effective:form', [name] + invoked_attributes)
         | 
| 47 55 | 
             
                  end
         | 
| 48 56 |  | 
| @@ -42,6 +42,10 @@ module Effective | |
| 42 42 | 
             
                  end
         | 
| 43 43 |  | 
| 44 44 | 
             
                  def invoke_datatable
         | 
| 45 | 
            +
                    unless invoked_actions.include?('index')
         | 
| 46 | 
            +
                      say_status(:skipped, :datatable, :yellow) and return
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
             | 
| 45 49 | 
             
                    Rails::Generators.invoke('effective:datatable', [name] + invoked_attributes)
         | 
| 46 50 | 
             
                  end
         | 
| 47 51 |  | 
| @@ -50,6 +54,10 @@ module Effective | |
| 50 54 | 
             
                  end
         | 
| 51 55 |  | 
| 52 56 | 
             
                  def invoke_form
         | 
| 57 | 
            +
                    unless invoked_actions.include?('new') || invoked_actions.include?('edit')
         | 
| 58 | 
            +
                      say_status(:skipped, :form, :yellow) and return
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
             | 
| 53 61 | 
             
                    Rails::Generators.invoke('effective:form', [name] + invoked_attributes)
         | 
| 54 62 | 
             
                  end
         | 
| 55 63 |  | 
| @@ -6,16 +6,20 @@ require_dependency '<%= namespaced_path %>/application_controller' | |
| 6 6 | 
             
            class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.presence, ApplicationController].compact.join('::') %>
         | 
| 7 7 | 
             
              before_action :authenticate_user! # Devise enforce user is present
         | 
| 8 8 |  | 
| 9 | 
            -
            <% if  | 
| 9 | 
            +
            <% if defined?(EffectiveResources) -%>
         | 
| 10 | 
            +
              include Effective::CrudController
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            <% end -%>
         | 
| 13 | 
            +
            <% if actions.delete('index') && !defined?(EffectiveResources) -%>
         | 
| 10 14 | 
             
              def index
         | 
| 11 15 | 
             
                @page_title = '<%= plural_name.titleize %>'
         | 
| 12 16 | 
             
                authorize! :index, <%= class_name %>
         | 
| 13 17 |  | 
| 14 | 
            -
                @datatable =  | 
| 18 | 
            +
                @datatable = <%= namespaced_class_name %>Datatable.new(params[:scopes])
         | 
| 15 19 | 
             
              end
         | 
| 16 20 |  | 
| 17 21 | 
             
            <% end -%>
         | 
| 18 | 
            -
            <% if actions.delete('new') -%>
         | 
| 22 | 
            +
            <% if actions.delete('new') && !defined?(EffectiveResources) -%>
         | 
| 19 23 | 
             
              def new
         | 
| 20 24 | 
             
                @<%= singular_name %> = <%= class_name %>.new
         | 
| 21 25 |  | 
| @@ -24,9 +28,9 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 24 28 | 
             
              end
         | 
| 25 29 |  | 
| 26 30 | 
             
            <% end -%>
         | 
| 27 | 
            -
            <% if actions.delete('create') -%>
         | 
| 31 | 
            +
            <% if actions.delete('create') && !defined?(EffectiveResources) -%>
         | 
| 28 32 | 
             
              def create
         | 
| 29 | 
            -
                @<%= singular_name %> = <%= class_name %>.new( | 
| 33 | 
            +
                @<%= singular_name %> = <%= class_name %>.new(<%= singular_name %>_params)
         | 
| 30 34 |  | 
| 31 35 | 
             
                @page_title = 'New <%= human_name %>'
         | 
| 32 36 | 
             
                authorize! :create, @<%= singular_name %>
         | 
| @@ -41,7 +45,7 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 41 45 | 
             
              end
         | 
| 42 46 |  | 
| 43 47 | 
             
            <% end -%>
         | 
| 44 | 
            -
            <% if actions.delete('show') -%>
         | 
| 48 | 
            +
            <% if actions.delete('show') && !defined?(EffectiveResources) -%>
         | 
| 45 49 | 
             
              def show
         | 
| 46 50 | 
             
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         | 
| 47 51 |  | 
| @@ -50,7 +54,7 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 50 54 | 
             
              end
         | 
| 51 55 |  | 
| 52 56 | 
             
            <% end -%>
         | 
| 53 | 
            -
            <% if actions.delete('edit') -%>
         | 
| 57 | 
            +
            <% if actions.delete('edit') && !defined?(EffectiveResources) -%>
         | 
| 54 58 | 
             
              def edit
         | 
| 55 59 | 
             
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         | 
| 56 60 |  | 
| @@ -59,14 +63,14 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 59 63 | 
             
              end
         | 
| 60 64 |  | 
| 61 65 | 
             
            <% end -%>
         | 
| 62 | 
            -
            <% if actions.delete('update') -%>
         | 
| 66 | 
            +
            <% if actions.delete('update') && !defined?(EffectiveResources) -%>
         | 
| 63 67 | 
             
              def update
         | 
| 64 68 | 
             
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         | 
| 65 69 |  | 
| 66 70 | 
             
                @page_title = "Edit #{@<%= singular_name %>}"
         | 
| 67 71 | 
             
                authorize! :update, @<%= singular_name %>
         | 
| 68 72 |  | 
| 69 | 
            -
                if @<%= singular_name %>.update_attributes( | 
| 73 | 
            +
                if @<%= singular_name %>.update_attributes(<%= singular_name %>_params)
         | 
| 70 74 | 
             
                  flash[:success] = 'Successfully updated <%= singular_name %>'
         | 
| 71 75 | 
             
                  redirect_to(redirect_path)
         | 
| 72 76 | 
             
                else
         | 
| @@ -76,7 +80,7 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 76 80 | 
             
              end
         | 
| 77 81 |  | 
| 78 82 | 
             
            <% end -%>
         | 
| 79 | 
            -
            <% if actions.delete('destroy') -%>
         | 
| 83 | 
            +
            <% if actions.delete('destroy') && !defined?(EffectiveResources) -%>
         | 
| 80 84 | 
             
              def destroy
         | 
| 81 85 | 
             
                @<%= singular_name %> = <%= class_name %>.find(params[:id])
         | 
| 82 86 | 
             
                authorize! :destroy, @<%= singular_name %>
         | 
| @@ -84,7 +88,7 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 84 88 | 
             
                if @<%= singular_name %>.destroy
         | 
| 85 89 | 
             
                  flash[:success] = 'Successfully deleted <%= singular_name %>'
         | 
| 86 90 | 
             
                else
         | 
| 87 | 
            -
                  flash | 
| 91 | 
            +
                  flash[:danger] = "Unable to delete <%= singular_name %>: #{@<%= singular_name %>.errors.full_messages.to_sentence}"
         | 
| 88 92 | 
             
                end
         | 
| 89 93 |  | 
| 90 94 | 
             
                redirect_to <%= index_path %>
         | 
| @@ -115,9 +119,9 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 115 119 | 
             
              end
         | 
| 116 120 |  | 
| 117 121 | 
             
            <% end -%>
         | 
| 118 | 
            -
               | 
| 122 | 
            +
              protected
         | 
| 119 123 |  | 
| 120 | 
            -
              def  | 
| 124 | 
            +
              def <%= singular_name %>_params
         | 
| 121 125 | 
             
                params.require(:<%= singular_name %>).permit(:id,
         | 
| 122 126 | 
             
            <% attributes_names.each_slice(8).with_index do |slice, index| -%>
         | 
| 123 127 | 
             
                  <%= slice.map { |name| permitted_param_for(name) }.join(', ') %><%= ',' if ((index+1) * 8) < attributes.length %>
         | 
| @@ -125,6 +129,7 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 125 129 | 
             
                )
         | 
| 126 130 | 
             
              end
         | 
| 127 131 |  | 
| 132 | 
            +
            <% if !defined?(EffectiveResources) -%>
         | 
| 128 133 | 
             
              def redirect_path
         | 
| 129 134 | 
             
                case params[:commit].to_s
         | 
| 130 135 | 
             
                when 'Save'
         | 
| @@ -138,5 +143,6 @@ class <%= namespaced_class_name %>Controller < <%= [namespace_path.classify.pres | |
| 138 143 | 
             
                end
         | 
| 139 144 | 
             
              end
         | 
| 140 145 |  | 
| 146 | 
            +
            <% end -%>
         | 
| 141 147 | 
             
            end
         | 
| 142 148 | 
             
            <% end -%>
         | 
| @@ -1,18 +1,14 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
              module Datatables
         | 
| 3 | 
            -
                class <%= namespaced_class_name %> < Effective::Datatable
         | 
| 1 | 
            +
            class <%= namespaced_class_name %>Datatable < Effective::Datatable
         | 
| 4 2 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 3 | 
            +
              datatable do<% attributes.each do |attribute| %>
         | 
| 4 | 
            +
                table_column :<%= attribute.name -%>
         | 
| 7 5 | 
             
            <% end %>
         | 
| 8 6 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
                  def collection
         | 
| 13 | 
            -
                    <%= class_name %>.all
         | 
| 14 | 
            -
                  end
         | 
| 7 | 
            +
                actions_column
         | 
| 8 | 
            +
              end
         | 
| 15 9 |  | 
| 16 | 
            -
             | 
| 10 | 
            +
              def collection
         | 
| 11 | 
            +
                <%= class_name %>.all
         | 
| 17 12 | 
             
              end
         | 
| 13 | 
            +
             | 
| 18 14 | 
             
            end
         | 
| @@ -3,7 +3,11 @@ | |
| 3 3 | 
             
              = f.input :<%= attribute.name %>
         | 
| 4 4 | 
             
            <% end -%>
         | 
| 5 5 |  | 
| 6 | 
            +
            <% if defined?(EffectiveResources) -%>
         | 
| 7 | 
            +
              = simple_form_submit(f)
         | 
| 8 | 
            +
            <% else -%>
         | 
| 6 9 | 
             
              %p.text-right
         | 
| 7 10 | 
             
                = f.button :submit, 'Save', data: { disable_with: 'Saving...' }
         | 
| 8 11 | 
             
                = f.button :submit, 'Save and Continue', data: { disable_with: 'Saving...' }
         | 
| 9 12 | 
             
                = f.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
         | 
| 13 | 
            +
            <% end -%>
         | 
| @@ -3,9 +3,11 @@ class <%= class_name %> < <%= parent_class_name.classify %> | |
| 3 3 | 
             
            <% attributes.select(&:reference?).each do |attribute| -%>
         | 
| 4 4 | 
             
              belongs_to :<%= attribute.name %><%= ', polymorphic: true' if attribute.polymorphic? %><%= ', required: true' if attribute.required? %>
         | 
| 5 5 | 
             
            <% end -%>
         | 
| 6 | 
            +
            <% if attributes.all? { |attribute| attribute.respond_to?(:token?) } -%>
         | 
| 6 7 | 
             
            <% attributes.select(&:token?).each do |attribute| -%>
         | 
| 7 8 | 
             
              has_secure_token<% if attribute.name != "token" %> :<%= attribute.name %><% end %>
         | 
| 8 9 | 
             
            <% end -%>
         | 
| 10 | 
            +
            <% end -%>
         | 
| 9 11 | 
             
            <% if attributes.any?(&:password_digest?) -%>
         | 
| 10 12 | 
             
              has_secure_password
         | 
| 11 13 | 
             
            <% end -%>
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: effective_developer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.10
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Code and Effect
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2017-01-10 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         |