Sha256: d88b2622bf301d56079940b8dde56a989353064440baff861ccb032c05a6c9d5

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module Orange
  class Slices < Orange::Resource
    call_me :slices
    def stack_init
      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

4 entries across 4 versions & 1 rubygems

Version Path
orange-0.2.5 lib/orange-more/slices/resources/slices.rb
orange-0.2.4 lib/orange-more/slices/resources/slices.rb
orange-0.2.3 lib/orange-more/slices/resources/slices.rb
orange-0.1.10 lib/orange-more/slices/resources/slices.rb