Sha256: f111c38db727c28b2983b0a46decb4a8a6b360fbf5fce8d3bdc04edd9cbf89e9

Contents?: true

Size: 557 Bytes

Versions: 6

Compression:

Stored size: 557 Bytes

Contents

module Fierce
  class ViewModel
    def initialize(*presenters)
      @presenters = presenters
    end

    def method_missing(method, *args, &block)
      responder = @presenters.find do |delegate|
        delegate.respond_to?(method, include_private=true)
      end

      responder ? responder.send(method, *args, &block) : super
    end

    def respond_to?(method, include_private=false)
      super(method, include_private) || @presenters.any?{|p| p.respond_to?(method)}
    end

    def yield(area = :layout)
      content_for(area)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fierce-0.2.0 lib/fierce/view_model.rb
fierce-0.1.4 lib/fierce/view_model.rb
fierce-0.1.3 lib/fierce/view_model.rb
fierce-0.1.2 lib/fierce/view_model.rb
fierce-0.1.1 lib/fierce/view_model.rb
fierce-0.1.0 lib/fierce/view_model.rb