Sha256: a58ad4dc83e7309427a3c587451b6a41242bfb5e706aa7345b921a422968d151

Contents?: true

Size: 507 Bytes

Versions: 2

Compression:

Stored size: 507 Bytes

Contents

module LanguageCards
  module Controllers
    class ApplicationController
      include Helpers::ViewHelper

      def initialize(opts = {})
        @opts = opts
      end

      def render(_binding)
        view = ERB.new IO.read File.expand_path("../view/#{snake name}.erb", __dir__)

        view.result(_binding)
      end

      private
      attr_reader :opts
      def name
        self.class.name.split('::').last
      end

      def errors
        Array(opts[:errors])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
language_cards-0.3.2 lib/language_cards/controllers/application_controller.rb
language_cards-0.3.1 lib/language_cards/controllers/application_controller.rb