Sha256: 25737d08ee2fe22c405d8c7843ea9456edf0c5b16e40472178b834def6dc3a67

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 KB

Contents

module Orange
  class Slices < Orange::Resource
    call_me :slices
    def stack_init
      orange[:radius].define_tag "slice" do |tag|
        content = ''
        resource = (tag.attr['resource'] || :slices).to_sym
        id = tag.attr['id'] || nil
        mode = (tag.attr['mode'] || tag.attr['chunk'] || (id ? :show : :index )).to_sym
        if orange.loaded?(resource)
          if orange[resource].respond_to?(mode) || resource == :slices
            content << (id ? orange[resource].__send__(mode, tag.locals.packet, :id => id) : orange[resource].__send__(mode, tag.locals.packet, {:attrs => tag.attr}))
          else
            content << "resource #{resource} doesn't respond to #{mode}"
          end
        else
          content << "resource #{resource} not loaded"
        end  
        content
      end
    end
    
    def view(packet, *args)
      mode = packet['route.resource_action']
      do_view(packet, mode, args.extract_options!)
    end
    
    def method_missing(mode, *args)
      packet = args.first if args.first.kind_of? Orange::Packet
      opts = args.extract_options!
      opts[:resource_name] = 'slices'
      do_view(packet, mode, opts)
    end
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
orange-more-0.5.8 lib/orange-more/slices/resources/slices.rb
orange-more-0.5.7 lib/orange-more/slices/resources/slices.rb
orange-0.5.5 lib/orange-more/slices/resources/slices.rb
orange-0.5.4 lib/orange-more/slices/resources/slices.rb
orange-0.5.3 lib/orange-more/slices/resources/slices.rb
orange-0.5.2 lib/orange-more/slices/resources/slices.rb
orange-0.5.1 lib/orange-more/slices/resources/slices.rb
orange-0.4.0 lib/orange-more/slices/resources/slices.rb
orange-0.3.9 lib/orange-more/slices/resources/slices.rb
orange-0.3.8 lib/orange-more/slices/resources/slices.rb
orange-0.3.7 lib/orange-more/slices/resources/slices.rb
orange-0.3.6 lib/orange-more/slices/resources/slices.rb
orange-0.3.5 lib/orange-more/slices/resources/slices.rb
orange-0.3.4 lib/orange-more/slices/resources/slices.rb