Sha256: 46f517e71104ece9703d59669b758d4aea91b733ee2ba789574756e0f2282705

Contents?: true

Size: 1.07 KB

Versions: 9

Compression:

Stored size: 1.07 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 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

9 entries across 9 versions & 1 rubygems

Version Path
orange-0.3.3 lib/orange-more/slices/resources/slices.rb
orange-0.3.2 lib/orange-more/slices/resources/slices.rb
orange-0.3.1 lib/orange-more/slices/resources/slices.rb
orange-0.3.0 lib/orange-more/slices/resources/slices.rb
orange-0.2.11 lib/orange-more/slices/resources/slices.rb
orange-0.2.9 lib/orange-more/slices/resources/slices.rb
orange-0.2.8 lib/orange-more/slices/resources/slices.rb
orange-0.2.7 lib/orange-more/slices/resources/slices.rb
orange-0.2.6 lib/orange-more/slices/resources/slices.rb