Module: AlmostHappy::ActiveRecordMixin::ClassMethods

Defined in:
lib/almost_happy/active_record_mixin.rb

Instance Method Summary collapse

Instance Method Details

#is_convertable(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/almost_happy/active_record_mixin.rb', line 7

def is_convertable(*args)
  include AlmostHappy::Convertable
  options = args.extract_options!
  fields  = args.map { |arg| arg.to_sym }.uniq
  self.convertable_fields += fields
  # Define accessors for each field.
  fields.each do |field|
    define_method(:"#{field}_as_html") { send(:"rendered_#{field}").to_s.html_safe }
  end
  validate_convertable_format if options.fetch(:validate, true)
end

#is_publishableObject



19
20
21
22
# File 'lib/almost_happy/active_record_mixin.rb', line 19

def is_publishable
  include AlmostHappy::Publishable
  include AlmostHappy::Scopeable
end