Module: BeautifiedUrl::ClassMethods

Defined in:
lib/beautified_url.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bu_attributes_hsetObject

Returns the value of attribute bu_attributes_hset.



10
11
12
# File 'lib/beautified_url.rb', line 10

def bu_attributes_hset
  @bu_attributes_hset
end

#bu_scope_setObject

Returns the value of attribute bu_scope_set.



11
12
13
# File 'lib/beautified_url.rb', line 11

def bu_scope_set
  @bu_scope_set
end

#bu_tokenObject

Returns the value of attribute bu_token.



9
10
11
# File 'lib/beautified_url.rb', line 9

def bu_token
  @bu_token
end

Instance Method Details

#beautify_url_with_scope(options) ⇒ Object



25
26
27
28
# File 'lib/beautified_url.rb', line 25

def beautify_url_with_scope(options)
  options = options.to_s if options.is_a?(Symbol)
  @bu_scope_set = options if options.is_a?(Hash) or options.is_a?(String)
end

#is_beautifiable?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/beautified_url.rb', line 13

def is_beautifiable?
  @bu_token ||= "_bu_"
  @bu_attributes_hset = {}
  attribute_names.each do |attribute_name|
    if attribute_name.starts_with?(@bu_token)
      p_attr = attribute_name.gsub(@bu_token, "") #parent attribute name
      @bu_attributes_hset[p_attr] = attribute_name if attribute_names.include?(p_attr)
    end
  end
  (not @bu_attributes_hset.empty?)
end