# File lib/graphiti/resource/links.rb, line 53 def primary_endpoint(path, actions = DEFAULT_ACTIONS.dup) path = path.to_sym self.endpoint = { path: path, full_path: full_path_for(path), url: url_for(path), actions: actions } end
module Graphiti::Links
Constants
- DEFAULT_ACTIONS
Public Instance Methods
Source
# File lib/graphiti/resource/links.rb, line 78 def allow_request?(request_path, params, action) request_path = request_path.split(".")[0] endpoints.any? do |e| has_id = params[:id] || params[:data].try(:[], :id) path = request_path if [:update, :show, :destroy].include?(action) && has_id path = request_path.split("/") path.pop if Graphiti::Util::UriDecoder.decode_uri(path.last) == has_id.to_s path = path.join("/") end e[:full_path].to_s == path && e[:actions].include?(action) end end
Source
# File lib/graphiti/resource/links.rb, line 74 def endpoints ([endpoint] + secondary_endpoints).compact end
Source
# File lib/graphiti/resource/links.rb, line 95 def full_path_for(path) [endpoint_namespace, path].join("").to_sym end
Source
# File lib/graphiti/resource/links.rb, line 41 def infer_endpoint return unless name path = "/#{name.gsub("Resource", "").pluralize.underscore}".to_sym { path: path, full_path: full_path_for(path), url: url_for(path), actions: DEFAULT_ACTIONS.dup } end
Source
Source
# File lib/graphiti/resource/links.rb, line 64 def secondary_endpoint(path, actions = DEFAULT_ACTIONS.dup) path = path.to_sym self.secondary_endpoints += [{ path: path, full_path: full_path_for(path), url: url_for(path), actions: actions }] end
NB: avoid << b/c class_attribute
Source
# File lib/graphiti/resource/links.rb, line 99 def url_for(path) [base_url, full_path_for(path)].join("").to_sym end