Module: Writefully::Postable
- Extended by:
- ActiveSupport::Concern
- Included in:
- Post
- Defined in:
- lib/writefully/postable.rb
Defined Under Namespace
Modules: ClassMethods
Classes: NoContentField
Instance Method Summary
collapse
Instance Method Details
#check_content_field_existence ⇒ Object
35
36
37
38
39
|
# File 'lib/writefully/postable.rb', line 35
def check_content_field_existence
unless respond_to?(:content)
raise NoContentField, "No content field defined please define a content field"
end
end
|
#klass_from(type_singular) ⇒ Object
23
24
25
|
# File 'lib/writefully/postable.rb', line 23
def klass_from type_singular
type_singular == "tag" ? "Writefully::Tag" : type_singular.classify
end
|
#publish_resource ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/writefully/postable.rb', line 27
def publish_resource
if publish
self.published_at = Time.now unless published_at.present?
else
self.published_at = nil
end
end
|
#taxonomize_with(tokens, type) ⇒ Object
17
18
19
20
21
|
# File 'lib/writefully/postable.rb', line 17
def taxonomize_with(tokens, type)
type_singular = type.to_s.singularize
type_klass = klass_from(type_singular).constantize
self.send(:"#{type_singular}_ids=", type_klass.ids_from_tokens(tokens))
end
|