Sha256: 90f13b3657c7bf4683753c2192a94a41b65f342769cdeaec6a674bb1bf5d0648

Contents?: true

Size: 723 Bytes

Versions: 16

Compression:

Stored size: 723 Bytes

Contents

module Arrest
  module HasView
    include Arrest::HasAttributes

    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      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.mod.const_get(clazz).new(self.context, r)
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
arrest-0.0.89 lib/arrest/helper/has_view.rb
arrest-0.0.88 lib/arrest/helper/has_view.rb
arrest-0.0.87 lib/arrest/helper/has_view.rb
arrest-0.0.86 lib/arrest/helper/has_view.rb
arrest-0.0.85 lib/arrest/helper/has_view.rb
arrest-0.0.84 lib/arrest/helper/has_view.rb
arrest-0.0.83.crud lib/arrest/helper/has_view.rb
arrest-0.0.83.1 lib/arrest/helper/has_view.rb
arrest-0.0.83 lib/arrest/helper/has_view.rb
arrest-0.0.82 lib/arrest/helper/has_view.rb
arrest-0.0.80 lib/arrest/helper/has_view.rb
arrest-0.0.79 lib/arrest/helper/has_view.rb
arrest-0.0.78 lib/arrest/helper/has_view.rb
arrest-0.0.77 lib/arrest/helper/has_view.rb
arrest-0.0.76 lib/arrest/helper/has_view.rb
arrest-0.0.75 lib/arrest/helper/has_view.rb