Sha256: 9ab9592446c64dac980af3a010a322373d1712568e5a7f00777dcc1b72ee2d35

Contents?: true

Size: 967 Bytes

Versions: 13

Compression:

Stored size: 967 Bytes

Contents

module Faalis
  module Generators
    module Concerns
      # This module adds `allow_query_on` key to json file which is an array
      # of field name which you want to whitelist for query.
      module AllowQueryOn

        private


        def allowed_fields
          if allowed_fields_provided?
            unless resource_data["allow_query_on"].is_a? Array
              raise Exception.new "value of `allow_query_on` key should be an Array. "
            end
            fields = resource_data["allow_query_on"].collect do |f|
              ":#{f}"
            end
            fields.join(" ,")
          else
            []
          end
        end

        # Check for any allowed fields in json
        def allowed_fields_provided?
          if resource_data.include? "allow_query_on"
            unless resource_data["allow_query_on"].nil?
              return true
            end
          end
          false
        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
faalis-1.0.0.alpha0 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.26.3 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.26.2 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.26.1 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.26.0 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.25.1 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.25.0 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.24.4 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.24.3 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.24.2 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.24.0 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.23.0 lib/faalis/generators/concerns/allow_query_on.rb
faalis-0.22.0 lib/faalis/generators/concerns/allow_query_on.rb