Module: Arrest::HasView::ClassMethods

Defined in:
lib/arrest/helper/has_view.rb

Instance Method Summary collapse

Instance Method Details

#has_view(*args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/arrest/helper/has_view.rb', line 10

def has_view(*args)

  method_name, options = args
  if options
    clazz = options[:class_name]
  end
  clazz ||= StringUtils.classify(method_name.to_s)

  send :define_method, method_name do
    @views ||= {}
    @views[method_name] ||= begin

      r = self.class.source().get(self.context, "#{self.resource_path}/#{id}/#{method_name}")
      r = self.class.body_root(r)

      Arrest::Source.class_loader.load(clazz).new(self.context, r)
    end
  end
end