Class: Tuttle::Presenters::ActiveRecord::ReflectionPresenter

Inherits:
BasePresenter
  • Object
show all
Defined in:
lib/tuttle/presenters/active_record/reflection_presenter.rb

Instance Method Summary collapse

Methods inherited from BasePresenter

#h, #initialize

Constructor Details

This class inherits a constructor from Tuttle::Presenters::BasePresenter

Instance Method Details

#foreign_keyObject



44
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 44

def foreign_key; super rescue 'Unknown' end

#inverse_ofObject



13
14
15
16
17
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 13

def inverse_of
  if has_inverse?
    h.(:span, has_inverse?.inspect, class: options[:inverse_of].present? ? 'specified' : 'autodetected')
  end
end

#macroObject



10
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 10

def macro; super.inspect end

#nameObject



9
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 9

def name; super.inspect end

#options_autosaveObject



35
36
37
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 35

def options_autosave
  h.true_label(options[:autosave].present?, 'autosave')
end

#options_class_nameObject



33
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 33

def options_class_name; options[:class_name] rescue 'Unknown' end

#options_dependentObject



32
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 32

def options_dependent; options[:dependent] rescue 'Unknown' end

#options_otherObject



46
47
48
49
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 46

def options_other
  other_options = options.except(:polymorphic, :dependent, :class_name, :autosave, :before_add, :before_remove)
  other_options.inspect unless other_options.empty?
end

#options_requiredObject



39
40
41
42
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 39

def options_required
  ## Todo handle auto-required?
  h.true_label(options[:required].present?, 'required')
end

#polymorphic?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 24

def polymorphic?
  h.true_label(super, 'polymorphic')
end

#scoped?Boolean

Returns:

  • (Boolean)


19
20
21
22
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 19

def scoped?
  # TODO: potentially show the scope
  h.true_label(scope.present?, 'scoped')
end

#typeObject



11
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 11

def type; super rescue 'Unknown' end

#validate?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/tuttle/presenters/active_record/reflection_presenter.rb', line 28

def validate?
  h.true_label(super, 'validate')
end