Sha256: b1540e8291cfb52438b5d862b287227395187fc455ea3f81a21ae468ddcdcda8
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
module Buoys class Buoy attr_reader :previous, :context # buoy :account do # link 'Account', account_path # end # # buoy :account_edit do |account| # link 'Account Show', show_account_path(account) # link 'Account Edit', edit_account_path(account) # pre_buoy :account # end def initialize(context, key, *args) block = Buoys::Loader.buoys[key] raise ArgumentError, "Buoys :#{key} is not found" unless block @key = key @context = context instance_exec(*args, &block) end def link(key, *args) options = args.extract_options! path = args.shift url = path ? context.url_for(path) : path text = I18n.t(key, scope: 'buoys.breadcrumbs', default: key) links << Buoys::Link.new(text, url, options) end def links @links ||= [] end def pre_buoy(key, *args) @previous = Buoys::Buoy.new(context, key, *args) end alias parent pre_buoy def method_missing(method, *args, &block) context.send(method, *args, &block) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
buoys-0.6.0 | lib/buoys/buoy.rb |
buoys-0.5.0 | lib/buoys/buoy.rb |
buoys-0.4.0 | lib/buoys/buoy.rb |