Sha256: e2c2af46ddf71aa3e6ef4521dbece428cc28b76ce86e3ce3689c4745f1357ca5

Contents?: true

Size: 830 Bytes

Versions: 8

Compression:

Stored size: 830 Bytes

Contents

class String

  def extract_settings
    split(",").map { |x| x.strip }
  end

  def remove_prefix(prefix = 'admin/')
    partition(prefix).last
  end

  def extract_resource
    remove_prefix
  end

  def extract_class
    remove_prefix.camelize.classify.constantize
  end

  def extract_human_name
    extract_class.model_name.human.gsub('/', ' ')
  end

  #--
  # OPTIMIZE: Find a way to remove the rescue.
  #++
  def typus_actions_on(filter)
    if settings = Typus::Configuration.config[self]['actions'][filter.to_s]
      settings.extract_settings
    else
      []
    end
  rescue
    []
  end

  #--
  # OPTIMIZE: Find a way to remove the rescue.
  #++
  def typus_defaults_for(filter)
    if settings = Typus::Configuration.config[self][filter.to_s]
      settings.extract_settings
    else
      []
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
typus-1.0.0.pre8 lib/support/string.rb
typus-1.0.0.pre7 lib/support/string.rb
typus-1.0.0.pre6 lib/support/string.rb
typus-1.0.0.pre5 lib/support/string.rb
typus-1.0.0.pre4 lib/support/string.rb
typus-1.0.0.pre3 lib/support/string.rb
typus-1.0.0.pre2 lib/support/string.rb
typus-1.0.0.pre lib/support/string.rb