Sha256: 6a010b9826cc41a15f1e7df710468076c7cc90417aa8c776eeaff94d7fcf1e5b

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

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

            def render?
              @crud_definition.actions.find { |action| action.name == 'update' }.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}/edit.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/edit_definition/presenter.rb
webamm_to_rails-7.0.0 lib/webamm_to_rails/sources/views/resource/edit_definition/presenter.rb