Sha256: 3c96c56fc8a29718443f9dcf07740d40079246a49a28f558a1ab6b19a606504f

Contents?: true

Size: 727 Bytes

Versions: 17

Compression:

Stored size: 727 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_one(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

17 entries across 17 versions & 1 rubygems

Version Path
arrest-0.0.74 lib/arrest/helper/has_view.rb
arrest-0.0.73 lib/arrest/helper/has_view.rb
arrest-0.0.72 lib/arrest/helper/has_view.rb
arrest-0.0.71 lib/arrest/helper/has_view.rb
arrest-0.0.70 lib/arrest/helper/has_view.rb
arrest-0.0.69 lib/arrest/helper/has_view.rb
arrest-0.0.68 lib/arrest/helper/has_view.rb
arrest-0.0.67 lib/arrest/helper/has_view.rb
arrest-0.0.66 lib/arrest/helper/has_view.rb
arrest-0.0.65 lib/arrest/helper/has_view.rb
arrest-0.0.64 lib/arrest/helper/has_view.rb
arrest-0.0.63 lib/arrest/helper/has_view.rb
arrest-0.0.62 lib/arrest/helper/has_view.rb
arrest-0.0.61 lib/arrest/helper/has_view.rb
arrest-0.0.60 lib/arrest/helper/has_view.rb
arrest-0.0.59 lib/arrest/helper/has_view.rb
arrest-0.0.58 lib/arrest/helper/has_view.rb