Sha256: d181fc52199b5e280e51963cc5a6390afa74368882139971f49735b61707a479

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

module WebammToRails
  module Sources
    module Views
      module Resource
        module NewDefinition
          class Presenter
            def initialize(crud_definition:)
              @crud_definition = crud_definition
            end

            def render?
              @crud_definition.actions.find { |action| action.name == 'create' }.present?
            end

            def render
              template_path = File.expand_path('template.erb', __dir__)
              template_content = File.read(template_path)
              raw_content = ERB.new(template_content, trim_mode: '-').result(instance_eval { binding })
              
              ::WebammToRails::Utils::FormatTemplate.call(raw_content)
            end

            def path_name
              "app/views/#{resource_name}/new.html.erb"
            end

            private

            def resource_name
              @crud_definition.table
            end

            def single_record_name
              @crud_definition.table.singularize
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webamm_to_rails-7.0.1 lib/webamm_to_rails/sources/views/resource/new_definition/presenter.rb
webamm_to_rails-7.0.0 lib/webamm_to_rails/sources/views/resource/new_definition/presenter.rb