This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# site_id AND... OWNER | |
scope = "nodes.site_id = #{visitor.site.id} AND (nodes.user_id = '#{visitor[:id]}' OR "+ | |
# OR READER if published | |
"(nodes.rgroup_id IN (#{visitor.group_ids.join(',')}) AND nodes.publish_from <= now() ) OR " + | |
# OR publisher if status is <> red | |
"(nodes.pgroup_id IN (#{visitor.group_ids.join(',')}) AND nodes.max_status <> #{Zena::Status[:red]}))" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb | |
index 0fefec1..2f5babe 100644 | |
--- a/activerecord/lib/active_record/associations/association_collection.rb | |
+++ b/activerecord/lib/active_record/associations/association_collection.rb | |
@@ -101,6 +101,7 @@ module ActiveRecord | |
else | |
build_record(attributes) do |record| | |
block.call(record) if block_given? | |
+ record.send(:"#{@owner.class.to_s.underscore}=", @owner) if record.respond_to?(:"#{@owner.class.to_s.underscore}=") | |
set_belongs_to_association_for(record) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Returns whether or not the parent, <tt>self</tt>, and any loaded autosave associations are valid. | |
def valid_with_autosave_associations? | |
record_valid = valid_without_autosave_associations? | |
self.class.reflect_on_all_autosave_associations.all? do |reflection| | |
if (association = association_instance_get(reflection.name)) && association.loaded? | |
if association.is_a?(Array) | |
association.proxy_target.all? { |child| autosave_association_valid?(reflection, child) } | |
else | |
autosave_association_valid?(reflection, association) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Value | |
{ | |
Value() : type_(NIL_TYPE_ID) {} | |
bool isReal() | |
{ return type_ == REAL_TYPE_ID; } | |
// special thing here: anonymous union | |
union { | |
real_t r; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* $Id$ */ | |
/*** | |
This file is part of avahi. | |
avahi is free software; you can redistribute it and/or modify it | |
under the terms of the GNU Lesser General Public License as | |
published by the Free Software Foundation; either version 2.1 of the | |
License, or (at your option) any later version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright: http://textile.thresholdstate.com/ */ | |
function span($text) | |
{ | |
$qtags = array('\*\*','\*','\?\?','-','__','_','%','\+','~','\^'); | |
$pnct = ".,\"'?!;:"; | |
foreach($qtags as $f) { | |
$text = preg_replace_callback("/ | |
(?:^|(?<=[\s>$pnct])|([{[])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Introduction | |
// ============ | |
// | |
// This is the heart of the Metro object: as its 'bang' method is called by a scheduler | |
// the metro object registers the next call in the scheduler with "bang_me_in" method. | |
// Things to know | |
// ============== | |
// | |
// 1. object attributes end with an underscore (run_, tempo_) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Redef | |
def foo | |
puts "'foo' from module" | |
end | |
end | |
class A | |
define_method("foo") do | |
puts "'foo' from define_method" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# real world example in zena: http://github.com/zena/zena/blob/master/lib/zena/acts/secure.rb | |
# in a module that you include where you need to find | |
def filter_fields(klass) | |
scope = {} | |
find_scope = scope[:find] = {} | |
find_scope[:select] = klass.fields_for(Thread.current.visitor).map {|f| "#{klass.table_name}.#{f}"}.join(',') | |
klass.send(:with_scope, scope) { yield } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
gem 'fast_gettext', '>=0.4.8' | |
require 'fast_gettext' | |
rescue LoadError | |
gem 'grosser-fast_gettext', '>=0.4.8' | |
end |
OlderNewer