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.1.27 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.26 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.25 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.24 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.23 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.22 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.21 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.20 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.19 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.18 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.17 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.16 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.15 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.14 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.13 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.12 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.11 lib/roqua/responders/active_interaction_aware_responder.rb
roqua-support-0.1.10 lib/roqua/responders/active_interaction_aware_responder.rb