Class: Pigeon::NestedAttribute

Inherits:
Object
  • Object
show all
Defined in:
app/models/pigeon/nested_attribute.rb

Direct Known Subclasses

ChannelAttribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, scope = nil) ⇒ NestedAttribute

Returns a new instance of NestedAttribute.



5
6
7
8
# File 'app/models/pigeon/nested_attribute.rb', line 5

def initialize(name, scope = nil)
  @name = name
  @scope = scope
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'app/models/pigeon/nested_attribute.rb', line 3

def name
  @name
end

#scopeObject (readonly)

Returns the value of attribute scope.



3
4
5
# File 'app/models/pigeon/nested_attribute.rb', line 3

def scope
  @scope
end

Instance Method Details

#scoped_name(prefix = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/pigeon/nested_attribute.rb', line 10

def scoped_name(prefix = nil)
  if scope.nil?
    if prefix.present?
      "#{prefix}[#{name}]"
    else
      name
    end
  else
    "#{scope.scoped_name(prefix)}[#{name}]"
  end
end