Sha256: 7476369c9b383e3550404ad402523395184af9f89a5bd43e33590ae4189b712c

Contents?: true

Size: 694 Bytes

Versions: 9

Compression:

Stored size: 694 Bytes

Contents

module Praxis
  module Extensions
    module FieldExpansion
      extend ActiveSupport::Concern

      included do
        Praxis::ActionDefinition.send(:include, ActionDefinitionExtension)
      end

      def expanded_fields
        @expansion ||= request.action.expanded_fields(self.request, self.media_type)
      end

      module ActionDefinitionExtension
        extend ActiveSupport::Concern

        def expanded_fields(request, media_type)
          uses_fields = self.params && self.params.attributes.key?(:fields)
          fields = uses_fields ? request.params.fields.fields : true

          Praxis::FieldExpander.expand(media_type,fields)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
praxis-2.0.pre.18 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.17 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.16 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.15 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.14 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.13 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.12 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.11 lib/praxis/extensions/field_expansion.rb
praxis-2.0.pre.10 lib/praxis/extensions/field_expansion.rb