Module: Smooth::Presentable::ClassMethods

Defined in:
lib/smooth/presentable.rb

Instance Method Summary collapse

Instance Method Details

#default_presenter_attributesObject



52
53
54
55
56
# File 'lib/smooth/presentable.rb', line 52

def default_presenter_attributes
  if respond_to?(:column_names)
    column_names.map(&:to_sym)
  end
end

#present(params = {}) ⇒ Object



68
69
70
71
72
73
# File 'lib/smooth/presentable.rb', line 68

def present params={}
  scope = scoped
  scope = query(params) if ancestors.include?(Smooth::Queryable)

  Smooth::Presentable::Chain.new(scope)
end

#presenter_classObject



48
49
50
# File 'lib/smooth/presentable.rb', line 48

def presenter_class
  "#{ to_s }Presenter".constantize rescue nil
end

#presenter_format_for_role(recipient = :default, format = :default) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/smooth/presentable.rb', line 58

def presenter_format_for_role(recipient=:default, format=:default)
  if presenter_class.respond_to?("#{ recipient }_#{ format }")
    "#{ recipient }_#{ format }"
  elsif presenter_class.respond_to?("#{ format }")
    format
  else
    :default
  end
end