Sha256: 31a443d3e8db77760721e77259c6395da4f224a907cc27ec17403c1199627436

Contents?: true

Size: 679 Bytes

Versions: 38

Compression:

Stored size: 679 Bytes

Contents

# For json and xml, will render the result of an active_interaction operation if no errors where present.
# Otherwise renders the interaction
module Roqua
  module Responders
    module ActiveInteractionAwareResponder
      def to_format
        if resource.is_a?(ActiveInteraction::Base)
          if resource.errors.empty?
            @resource = resource.result
            @resources[-1] = resource
          end
        end
        super
      end

      def json_resource_errors
        if !resource.is_a?(ActiveInteraction::Base) || resource.errors.empty?
          super
        else
          {:errors => resource.errors.as_json}
        end
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
roqua-support-0.4.6 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.4.5 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.4.4 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.4.3 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.4.2 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.4.1 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.4.0 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.3.5 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.3.4 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.3.3 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.3.2 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.3.1 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.3.0 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.34 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.33 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.32 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.31 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.30 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.29 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.28 lib/roqua/responders/active_interaction_aware_responder.rb