Sha256: fcbc3afb77cd0e89a8c89ccb0bce595b323b177e62f712fe7fdcdfef857ca92d

Contents?: true

Size: 1.09 KB

Versions: 36

Compression:

Stored size: 1.09 KB

Contents

module Lolita
  module Configuration
    class Action

      include Lolita::Builder
      lolita_accessor :url
      attr_writer :title,:html
      attr_reader :name

      def initialize(dbi,name, options ={}, &block)
        @dbi = dbi
        @name = name
        options.each do |key,value|
          self.send(:"#{key}=",value)
        end
        instance_eval(&block) if block_given?
      end

      def html attributes = nil
        if attributes
          @html = attributes
        else
          result = {}
          (@html || {}).each{|k,v|
            result[k] = v.respond_to?(:call) ? v.call : v
          }
          result
        end
      end

      def title value=nil
        if value
          @title = value
        else
          if @title
            @title.respond_to?(:call) ? @title.call : @title
          else
            ::I18n.t("#{@dbi.klass.to_s.underscore}.actions.#{@name}")
          end
        end
      end

      def view_url view, record
        if @url.respond_to?(:call)
          @url.call(view,record)
        else
          @url
        end
      end

    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
lolita-4.0.11 lib/lolita/configuration/action.rb
lolita-4.2.0 lib/lolita/configuration/action.rb
lolita-4.0.10 lib/lolita/configuration/action.rb
lolita-4.0.9 lib/lolita/configuration/action.rb
lolita-4.0.8 lib/lolita/configuration/action.rb
lolita-4.0.7 lib/lolita/configuration/action.rb
lolita-4.0.6 lib/lolita/configuration/action.rb
lolita-4.0.5 lib/lolita/configuration/action.rb
lolita-4.0.4 lib/lolita/configuration/action.rb
lolita-4.0.3 lib/lolita/configuration/action.rb
lolita-4.0.2 lib/lolita/configuration/action.rb
lolita-4.0.1 lib/lolita/configuration/action.rb
lolita-4.0.0 lib/lolita/configuration/action.rb
lolita-3.4.3 lib/lolita/configuration/action.rb
lolita-3.4.2 lib/lolita/configuration/action.rb
lolita-3.4.1 lib/lolita/configuration/action.rb
lolita-3.4.0 lib/lolita/configuration/action.rb
lolita-3.3.9 lib/lolita/configuration/action.rb
lolita-3.3.8 lib/lolita/configuration/action.rb
lolita-3.3.7 lib/lolita/configuration/action.rb