Sha256: 16360b67ebc9dc72b3d6489d0ac466bcdfb802b69a8bd610d01483a285e23559

Contents?: true

Size: 796 Bytes

Versions: 1

Compression:

Stored size: 796 Bytes

Contents

class RailsViews
  module ViewHelpers
    extend ActiveSupport::Concern

    def flash
      parent_controller.flash
    end

    def render_each_and_join(views)
      views.map { |view| render(view) }.join
    end

    class_methods do
      def option(*array)
        array.each do |option|
          define_method(option) do
            options[option]
          end
        end
      end

      def date_property(*array)
        options = array.pop if array.last.is_a?(Hash)
        options ||= {}
        array.each do |field|
          format = options[:format] || :default
          name = options[:prefix] ? "#{options[:prefix]}_#{field}" : field
          define_method(name) do
            I18n.l(model.send(field), format: format)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_views-0.1.0 lib/rails_views/view_helpers.rb