module Dome::ViewMethods
Public Instance Methods
exhibit(thing, by: nil, to: dome_view_context)
click to toggle source
exhibit(@one) exhibit(@one, by: SomeEx)
# File lib/dome/view_methods.rb, line 23 def exhibit(thing, by: nil, to: dome_view_context) klass = by || begin class_name = "#{thing.class.name}Exhibit" klass = class_name.safe_constantize klass || raise( Dome::ExhibitClassNotFound, "Exhibit class '#{class_name}' for '#{thing.inspect}' not found." ) end exhibited = klass.new(thing) exhibited.instance_variable_set("@view_context", to) exhibited end
exhibit_enum(things, by: nil, to: dome_view_context)
click to toggle source
exhibit_enum
(@ones) exhibit_enum
(@ones, by: SomeEx)
# File lib/dome/view_methods.rb, line 40 def exhibit_enum(things, by: nil, to: dome_view_context) klass = by || begin class_name = "#{things.first.class.name}Exhibit" klass = class_name.safe_constantize klass || raise( Dome::ExhibitClassNotFound, "Exhibit class '#{class_name}' for '#{things.first.inspect}' not found." ) end exhibited_enum = things.map do |x| exhibited = klass.new(x) exhibited.instance_variable_set("@view_context", to) exhibited end exhibited_enum end
present(name, *vals, to: dome_view_context)
click to toggle source
present(:pair, @one, @two)
# File lib/dome/view_methods.rb, line 8 def present(name, *vals, to: dome_view_context) class_name = "#{name.to_s.camelize}Presenter" klass = class_name.safe_constantize klass || raise( Dome::PresenterClassNotFound, "Presenter class '#{class_name}' for '#{name}' not found." ) presented = klass.new(*vals) presented.instance_variable_set("@view_context", to) presented end
Private Instance Methods
dome_view_context()
click to toggle source
# File lib/dome/view_methods.rb, line 60 def dome_view_context @dome_view_context ||= respond_to?(:view_context) ? view_context : self end