Class: Scopiform::ScopeDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/scopiform/scope_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute, prefix: nil, suffix: nil, **options) ⇒ ScopeDefinition

Returns a new instance of ScopeDefinition.



5
6
7
8
9
10
# File 'lib/scopiform/scope_definition.rb', line 5

def initialize(attribute, prefix: nil, suffix: nil, **options)
  @attribute = attribute.to_sym
  @prefix = prefix
  @suffix = suffix
  @options = options
end

Instance Attribute Details

#attributeObject

Returns the value of attribute attribute.



3
4
5
# File 'lib/scopiform/scope_definition.rb', line 3

def attribute
  @attribute
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/scopiform/scope_definition.rb', line 3

def options
  @options
end

#prefixObject

Returns the value of attribute prefix.



3
4
5
# File 'lib/scopiform/scope_definition.rb', line 3

def prefix
  @prefix
end

#suffixObject

Returns the value of attribute suffix.



3
4
5
# File 'lib/scopiform/scope_definition.rb', line 3

def suffix
  @suffix
end

Instance Method Details

#dupObject



20
21
22
23
24
25
# File 'lib/scopiform/scope_definition.rb', line 20

def dup
  duplicate = super
  duplicate.options = options.dup

  duplicate
end

#nameObject



12
13
14
# File 'lib/scopiform/scope_definition.rb', line 12

def name
  name_for(attribute)
end

#name_for(attribute_name) ⇒ Object



16
17
18
# File 'lib/scopiform/scope_definition.rb', line 16

def name_for(attribute_name)
  "#{prefix}#{attribute_name}#{suffix}".underscore.to_sym
end