Class: WebammToRails::Sources::Controllers::Actions::EditDefinition::Presenter

Inherits:
Object
  • Object
show all
Defined in:
lib/webamm_to_rails/sources/controllers/actions/edit_definition/presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(table_name:, crud_definition:) ⇒ Presenter

Returns a new instance of Presenter.



7
8
9
10
# File 'lib/webamm_to_rails/sources/controllers/actions/edit_definition/presenter.rb', line 7

def initialize(table_name:, crud_definition:)
  @table_name = table_name
  @crud_definition = crud_definition
end

Instance Method Details

#access_scopeObject



20
# File 'lib/webamm_to_rails/sources/controllers/actions/edit_definition/presenter.rb', line 20

def access_scope = :public

#renderObject



12
13
14
15
16
17
18
# File 'lib/webamm_to_rails/sources/controllers/actions/edit_definition/presenter.rb', line 12

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::FormatCode.call(raw_content)
end

#render?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/webamm_to_rails/sources/controllers/actions/edit_definition/presenter.rb', line 22

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