Defines a nested route or not and retrieves the correct resource (or resources)
 @param disables is the name to check if it was disabled
 @param &block to be yield with the retrieved resource
 @returns resource in json format
331928
def retrieve_resources(action)
      pass unless involved?
      no_route if disabled? action

      model = model_name.constantize
      nested = nested_resources if nested?

      if model.nil? || nested.nil? && nested?
        raise ActiveRecord::RecordNotFound
      else
        resource = nested? ? nested : model

        # Check access to the resource
        method = "limit_#{action}_for".to_sym
        resource = self.class.send(method, resource, current_user) if self.class.respond_to?(method) && !current_user.nil?

        # ONE resource else COLLECTION
        one_id = nested? ? params[:captures].fourth : params[:captures].second if params[:captures].length == 4
        resource = resource.find one_id unless one_id.nil?
        yield(resource).to_json
      end
    rescue ActiveRecord::RecordNotFound
      record_not_found.to_json
    end
339706
def map(&block)
      collection = []

      each do |connection|
        collection << block.call(connection) if block
      end

      collection
    end
947311
function Router(options) {
  if ( !(this instanceof Router) ) {
    return new Router(options);
  }
  options = options || {};
  var self = this;
  this.routes = [];
  this.caseSensitive = options.caseSensitive;
  this.strict = options.strict;
  this.connect = connect();
  this.middleware = function (req, res, next){
    dispatch(self, req, res, next);
  };
  this.eventHandlers = {
    404 : function(req, res){
      res.writeHead(404);
      res.end('Not found');
    },
    405 : function(req, res, resource){
      res.setHeader('Allow', allowHeader(self, resource));
      res.writeHead(405);
      res.end('Not allowed');
    },
    'HEAD' : function(req, res, resource){
      if (!resource.GET){
        return self.eventHandlers[405](req, res, resource);
      }
      // node server suppresses the response output
      // on a HEAD response so we don't need to mute it like this:
      /*

      var origResWrite = res.write;
      var origResEnd = res.end;

      res.write = function(){
        origResWrite.apply(res, ['']);
      };
      res.end = function(){
        console.log("in muted end()");
        origResEnd.apply(res, ['']);
      };
      */
      // re-distpach as a GET
      req.method = "GET";
      return dispatch(self, req, res, function(){});
    },
    'OPTIONS' : function(req, res, resource){
      var header = allowHeader(self, resource);
      res.setHeader('Allow', header);
      res.writeHead(200);
      res.end('Allow: ' + header);
    }
  };
  // we never tackle 501, because the node server just drops requests
  // with invalid methods
}
82828
private Map<String, Object> getIncludedResources(JsonNode parent)
			throws IOException, IllegalAccessException, InstantiationException {
		Map<String, Object> result = new HashMap<>();

		if (parent.has(INCLUDED)) {
			for (JsonNode jsonNode : parent.get(INCLUDED)) {
				String type = jsonNode.get(TYPE).asText();

				Class<?> clazz = configuration.getTypeClass(type);

				if (clazz != null) {
					Object object = readObject(jsonNode, clazz, false);
					if (object != null) {
						result.put(createIdentifier(jsonNode), object);
					}
				} else if (!deserializationFeatures.contains(DeserializationFeature.ALLOW_UNKNOWN_INCLUSIONS)) {
					throw new IllegalArgumentException("Included section contains unknown resource type: " + type);
				}
			}
		}

		return result;
	}
526015
public static base_responses disable(nitro_service client, service resources[]) throws Exception {
		base_responses result = null;
		if (resources != null && resources.length > 0) {
			service disableresources[] = new service[resources.length];
			for (int i=0;i<resources.length;i++){
				disableresources[i] = new service();
				disableresources[i].name = resources[i].name;
				disableresources[i].delay = resources[i].delay;
				disableresources[i].graceful = resources[i].graceful;
			}
			result = perform_operation_bulk_request(client, disableresources,"disable");
		}
		return result;
	}
1176875
@Override
  public BlockLocationsResponse getBlockLocations(GetBlockLocationsRequest req) throws IOException {
    Server.setOrignalCaller(req.getOriginalCaller());
    return new BlockLocationsResponse(getBlockLocationsInternal(req.getSrc(), req.getOffset(),
        req.getLength(), BlockMetaInfoType.NONE));
  }
642231
function(options, key) {
        // a protected resource defaults to a 'user' role
        var options = options===true?{ path: key, roles: ['user'] }:options;
        var path = options.path;

        // only features that have defined 'path' AND 'roles'
        if (!options.roles || !path) {
            debug("missing %s roles for %s", key, path);
            return;
        }

        DEBUG && debug("protect: %s @ %s", key, path)
        router.use(path, function(req,res,next) {
            DEBUG && debug("PROTECTED: %s @ %s -> %j", path, req.path, options.roles);
            EnsureAuthenticated(req, res, false) && EnsureAuthorized(options, req, res, next)
        })
    }
434204
def define(&block)
      if block && block.arity > 0
        block.call @ns
      elsif block
        @ns.instance_eval(&block)
      end
      @ns
    end
1133458
@SuppressWarnings("unchecked")
    @Override
    public V get(Block<?, ?> block) {
        return (V) storage[block.getId()];
    }
127416
def handle_json_GET_routes(self, params):
    """"""
    schedule = self.server.schedule
    result = []
    for r in schedule.GetRouteList():
      result.append( (r.route_id, r.route_short_name, r.route_long_name) )
    result.sort(key = lambda x: x[1:3])
    return result
292393
@CheckForNull
  public Block first(String resourceId) {
    for (Block block : blocks) {
      if (resourceId.equals(block.getResourceId())) {
        return block;
      }
    }
    return null;
  }
1136201
def each
      return to_enum unless block_given?
      super do |resource|
        begin
          original, resource.collection = resource.collection, self
          yield resource
        ensure
          resource.collection = original
        end
      end
    end
68679
public static BlockLocation[] locatedBlocks2Locations(LocatedBlocks blocks) {
    if (blocks == null) {
      return new BlockLocation[0];
    }
    int nrBlocks = blocks.locatedBlockCount();
    BlockLocation[] blkLocations = new BlockLocation[nrBlocks];
    if (nrBlocks == 0) {
      return blkLocations;
    }
    int idx = 0;
    for (LocatedBlock blk : blocks.getLocatedBlocks()) {
      assert idx < nrBlocks : "Incorrect index";
      DatanodeInfo[] locations = blk.getLocations();
      String[] hosts = new String[locations.length];
      String[] names = new String[locations.length];
      String[] racks = new String[locations.length];
      for (int hCnt = 0; hCnt < locations.length; hCnt++) {
        hosts[hCnt] = locations[hCnt].getHostName();
        names[hCnt] = locations[hCnt].getName();
        NodeBase node = new NodeBase(names[hCnt],
                                     locations[hCnt].getNetworkLocation());
        racks[hCnt] = node.toString();
      }
      blkLocations[idx] = new BlockLocation(names, hosts, racks,
                                            blk.getStartOffset(),
                                            blk.getBlockSize(),
                                            blk.isCorrupt());
      idx++;
    }
    return blkLocations;
  }
1344230
public function show(ReadBlockInterface $block)
    {
        $parameters = $this->requestStack->getMasterRequest()->get('_route_params');
        if (!array_key_exists('siteId', $parameters) || !array_key_exists('nodeId', $parameters)) {
            throw new RouteNotFoundException();
        }
        $site = $this->siteRepository->findOneBySiteId($parameters['siteId']);
        $routes = array();
        if (!\is_null($site)) {
            foreach ($site->getLanguages() as $language) {
                try {
                    unset($parameters['_locale']);
                    unset($parameters['aliasId']);

                    $routes[$language] = $this->urlGenerator->generate($parameters['nodeId'], array_merge(
                        $parameters,
                        array(OpenOrchestraDatabaseUrlGenerator::REDIRECT_TO_LANGUAGE => $language)
                    ));
                } catch (ResourceNotFoundException $e) {
                } catch (RouteNotFoundException $e) {
                } catch (MissingMandatoryParametersException $e) {
                }
            }
        }

        return $this->render(
            $this->template,
            array(
                'class' => $block->getStyle(),
                'id' => $block->getId(),
                'routes' => $routes,
            )
        );
    }
546044
def create
      @block = Block.builder(params)

      if @block.save
        render json: { status: :success }, status: :ok
      else
        render json: @block.errors, status: :unprocessable_entity
      end
    end
663381
def my(*params, &block)
      options = {:query => {}}
      options[:query] = params[0] if params.length > 0
      response = self.class.get "/contractors/my", options
      yield(response) if block_given?
      response
    end
619101
protected Block visitBlock(Block block) {
        if (block == null) {
            return null;
        }

        Statement stmt = (Statement)block.accept(this);

        if (stmt instanceof Block) {
            return (Block)stmt;
        }
        else if (stmt != null) {
            return new Block(stmt);
        }
        else {
            return new Block(block.getSourceInfo());
        }
    }