Module: ActiveRecord::Mlang::Text::ClassMethods
- Defined in:
- lib/active_record/mlang/text.rb
Instance Method Summary collapse
-
#parent_ ⇒ Object
parent is used.
- #parent_class_name(parent_class_name = nil) ⇒ Object
- #parent_class_name=(parent_class_name) ⇒ Object
- #parent_fkey(parent_fkey = nil) ⇒ Object
- #parent_fkey=(parent_fkey) ⇒ Object
- #set_parent_reflection ⇒ Object
Instance Method Details
#parent_ ⇒ Object
parent is used
46 47 48 |
# File 'lib/active_record/mlang/text.rb', line 46 def parent_ # parent is used self.parent_class_name.safe_constantize end |
#parent_class_name(parent_class_name = nil) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/active_record/mlang/text.rb', line 11 def parent_class_name(parent_class_name=nil) if parent_class_name self.parent_class_name = parent_class_name else @parent_class_name || self.name.gsub(/Text$/,'') end end |
#parent_class_name=(parent_class_name) ⇒ Object
19 20 21 22 23 |
# File 'lib/active_record/mlang/text.rb', line 19 def parent_class_name=(parent_class_name) @parent_class_name = parent_class_name.to_s set_parent_reflection self end |
#parent_fkey(parent_fkey = nil) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/active_record/mlang/text.rb', line 25 def parent_fkey(parent_fkey=nil) if parent_fkey self.parent_fkey = parent_fkey else @parent_fkey || :parent_id end end |
#parent_fkey=(parent_fkey) ⇒ Object
33 34 35 36 37 |
# File 'lib/active_record/mlang/text.rb', line 33 def parent_fkey=(parent_fkey) @parent_fkey = parent_fkey set_parent_reflection self end |
#set_parent_reflection ⇒ Object
39 40 41 42 43 44 |
# File 'lib/active_record/mlang/text.rb', line 39 def set_parent_reflection belongs_to :parent, class_name: self.parent_class_name, foreign_key: self.parent_fkey if p = self.parent_ && p.respond_to?(:set_text_reflection) p.set_text_reflection end end |