Module: PassiveRecord::Associations
- Defined in:
- lib/passive_record/associations.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #attribute_present?(attribute) ⇒ Boolean
- #new_record? ⇒ Boolean
-
#quoted_id ⇒ Object
:nodoc:.
- #read_attribute(attribute) ⇒ Object
Class Method Details
.included(base) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/passive_record/associations.rb', line 6 def self.included(base) base.extend(ClassMethods) ActiveRecord::Callbacks::CALLBACKS.each do |method| base.class_eval <<-"end_eval" def self.#{method}(*callbacks, &block) callbacks << block if block_given? write_inheritable_array(#{method.to_sym.inspect}, callbacks) end end_eval end end |
Instance Method Details
#attribute_present?(attribute) ⇒ Boolean
23 24 25 26 |
# File 'lib/passive_record/associations.rb', line 23 def attribute_present?(attribute) value = self.respond_to?(attribute) ? self.send(attribute) : nil !value.blank? or value == 0 end |
#new_record? ⇒ Boolean
32 33 34 |
# File 'lib/passive_record/associations.rb', line 32 def new_record? false end |
#quoted_id ⇒ Object
:nodoc:
19 20 21 |
# File 'lib/passive_record/associations.rb', line 19 def quoted_id #:nodoc: ActiveRecord::Base.quote_value(self.key) end |
#read_attribute(attribute) ⇒ Object
28 29 30 |
# File 'lib/passive_record/associations.rb', line 28 def read_attribute(attribute) self.send(attribute) end |