Sha256: 1af727ff151f6dcd41bda7a9d92f474a8ea8fb6af580d11f81b6e19d7e2edec3

Contents?: true

Size: 1.13 KB

Versions: 13

Compression:

Stored size: 1.13 KB

Contents

module Orange
  class Slices < Orange::Resource
    call_me :slices
    def afterLoad
      orange.register(:stack_loaded){
        orange[:radius].context.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))
            else
              content << "resource #{resource} doesn't respond to #{mode}"
            end
          else
            content << "resource #{resource} not loaded"
          end  
          content
        end
      }
    end
    
    
    def method_missing(mode, *args)
      packet = args.first if args.first.kind_of? Orange::Packet
      opts = args.extract_options!
      opts[:resource_name] = 'slices'
      orange[:parser].haml("#{mode.to_s}.haml", packet, opts)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
orange-0.1.8 lib/orange-more/slices/resources/slices.rb
orange-0.1.7 lib/orange-more/slices/resources/slices.rb
orange-0.1.4 lib/orange-more/slices/resources/slices.rb
orange-0.1.2 lib/orange-more/slices/resources/slices.rb
orange-0.1.0 lib/orange-more/slices/resources/slices.rb
orange-0.0.15 lib/orange-more/slices/resources/slices.rb
orange-0.0.14 lib/orange-more/slices/resources/slices.rb
orange-0.0.13 lib/orange/resources/slices.rb
orange-0.0.12 lib/orange/resources/slices.rb
orange-0.0.10 lib/orange/resources/slices.rb
orange-0.0.8 lib/orange/resources/slices.rb
orange-0.0.7 lib/orange/resources/slices.rb
orange-0.0.6 lib/orange/resources/slices.rb