Module: Upmin::Railties::ActiveRecord
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/upmin/railties/active_record.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #notify_upmin_of_save ⇒ Object
- #upmin_associations ⇒ Object
- #upmin_attr_editable?(attr_name) ⇒ Boolean
- #upmin_attr_type(attr_name) ⇒ Object
- #upmin_attributes ⇒ Object
- #upmin_collection_reflections ⇒ Object
- #upmin_color ⇒ Object
- #upmin_get_assoc(assoc_name) ⇒ Object
- #upmin_get_attr(attr_name) ⇒ Object
- #upmin_name(type = :plural) ⇒ Object
Instance Method Details
#notify_upmin_of_save ⇒ Object
11 12 13 |
# File 'lib/upmin/railties/active_record.rb', line 11 def notify_upmin_of_save # TODO(jon): Add after_save notifications. end |
#upmin_associations ⇒ Object
19 20 21 |
# File 'lib/upmin/railties/active_record.rb', line 19 def upmin_associations return self.class.upmin_associations end |
#upmin_attr_editable?(attr_name) ⇒ Boolean
35 36 37 38 39 40 41 |
# File 'lib/upmin/railties/active_record.rb', line 35 def upmin_attr_editable?(attr_name) return false if attr_name.to_sym == :id return false if attr_name.to_sym == :created_at return false if attr_name.to_sym == :updated_at # TODO(jon): Add a way to lock this later return self.respond_to?("#{attr_name}=") end |
#upmin_attr_type(attr_name) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/upmin/railties/active_record.rb', line 43 def upmin_attr_type(attr_name) if uc = self.class.columns_hash[attr_name.to_s] return uc.type else return :unknown end end |
#upmin_attributes ⇒ Object
15 16 17 |
# File 'lib/upmin/railties/active_record.rb', line 15 def upmin_attributes return self.class.upmin_attributes end |
#upmin_collection_reflections ⇒ Object
23 24 25 |
# File 'lib/upmin/railties/active_record.rb', line 23 def upmin_collection_reflections return self.class.upmin_collection_reflections end |
#upmin_color ⇒ Object
31 32 33 |
# File 'lib/upmin/railties/active_record.rb', line 31 def upmin_color return self.class.upmin_color end |
#upmin_get_assoc(assoc_name) ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/upmin/railties/active_record.rb', line 55 def upmin_get_assoc(assoc_name) assoc_name = assoc_name.to_sym if upmin_collection_reflections.include?(assoc_name) return send(assoc_name).limit(5) else return send(assoc_name) end end |
#upmin_get_attr(attr_name) ⇒ Object
51 52 53 |
# File 'lib/upmin/railties/active_record.rb', line 51 def upmin_get_attr(attr_name) return send(attr_name) end |
#upmin_name(type = :plural) ⇒ Object
27 28 29 |
# File 'lib/upmin/railties/active_record.rb', line 27 def upmin_name(type = :plural) return self.class.upmin_name(type) end |