Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 3457 Bytes
1 | class Pirate < ActiveRecord::Base |
2 | belongs_to :parrot, :validate => true |
3 | belongs_to :non_validated_parrot, :class_name => 'Parrot' |
4 | has_and_belongs_to_many :parrots, :validate => true |
5 | has_and_belongs_to_many :non_validated_parrots, :class_name => 'Parrot' |
6 | has_and_belongs_to_many :parrots_with_method_callbacks, :class_name => "Parrot", |
7 | :before_add => :log_before_add, |
8 | :after_add => :log_after_add, |
9 | :before_remove => :log_before_remove, |
10 | :after_remove => :log_after_remove |
11 | has_and_belongs_to_many :parrots_with_proc_callbacks, :class_name => "Parrot", |
12 | :before_add => proc {|p,pa| p.ship_log << "before_adding_proc_parrot_#{pa.id || '<new>'}"}, |
13 | :after_add => proc {|p,pa| p.ship_log << "after_adding_proc_parrot_#{pa.id || '<new>'}"}, |
14 | :before_remove => proc {|p,pa| p.ship_log << "before_removing_proc_parrot_#{pa.id}"}, |
15 | :after_remove => proc {|p,pa| p.ship_log << "after_removing_proc_parrot_#{pa.id}"} |
16 | |
17 | has_many :treasures, :as => :looter |
18 | has_many :treasure_estimates, :through => :treasures, :source => :price_estimates |
19 | |
20 | # These both have :autosave enabled because accepts_nested_attributes_for is used on them. |
21 | has_one :ship |
22 | has_one :update_only_ship, :class_name => 'Ship' |
23 | has_one :non_validated_ship, :class_name => 'Ship' |
24 | has_many :birds |
25 | has_many :birds_with_method_callbacks, :class_name => "Bird", |
26 | :before_add => :log_before_add, |
27 | :after_add => :log_after_add, |
28 | :before_remove => :log_before_remove, |
29 | :after_remove => :log_after_remove |
30 | has_many :birds_with_proc_callbacks, :class_name => "Bird", |
31 | :before_add => proc {|p,b| p.ship_log << "before_adding_proc_bird_#{b.id || '<new>'}"}, |
32 | :after_add => proc {|p,b| p.ship_log << "after_adding_proc_bird_#{b.id || '<new>'}"}, |
33 | :before_remove => proc {|p,b| p.ship_log << "before_removing_proc_bird_#{b.id}"}, |
34 | :after_remove => proc {|p,b| p.ship_log << "after_removing_proc_bird_#{b.id}"} |
35 | has_many :birds_with_reject_all_blank, :class_name => "Bird" |
36 | |
37 | accepts_nested_attributes_for :parrots, :birds, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } |
38 | accepts_nested_attributes_for :ship, :allow_destroy => true, :reject_if => proc { |attributes| attributes.empty? } |
39 | accepts_nested_attributes_for :update_only_ship, :update_only => true |
40 | accepts_nested_attributes_for :parrots_with_method_callbacks, :parrots_with_proc_callbacks, |
41 | :birds_with_method_callbacks, :birds_with_proc_callbacks, :allow_destroy => true |
42 | accepts_nested_attributes_for :birds_with_reject_all_blank, :reject_if => :all_blank |
43 | |
44 | validates_presence_of :catchphrase |
45 | |
46 | def ship_log |
47 | @ship_log ||= [] |
48 | end |
49 | |
50 | def reject_empty_ships_on_create(attributes) |
51 | attributes.delete('_reject_me_if_new').present? && new_record? |
52 | end |
53 | |
54 | attr_accessor :cancel_save_from_callback |
55 | before_save :cancel_save_callback_method, :if => :cancel_save_from_callback |
56 | def cancel_save_callback_method |
57 | false |
58 | end |
59 | |
60 | private |
61 | def log_before_add(record) |
62 | log(record, "before_adding_method") |
63 | end |
64 | |
65 | def log_after_add(record) |
66 | log(record, "after_adding_method") |
67 | end |
68 | |
69 | def log_before_remove(record) |
70 | log(record, "before_removing_method") |
71 | end |
72 | |
73 | def log_after_remove(record) |
74 | log(record, "after_removing_method") |
75 | end |
76 | |
77 | def log(record, callback) |
78 | ship_log << "#{callback}_#{record.class.name.downcase}_#{record.id || '<new>'}" |
79 | end |
80 | end |