Class: Pigeon::NestedAttribute
- Inherits:
-
Object
- Object
- Pigeon::NestedAttribute
- Defined in:
- app/models/pigeon/nested_attribute.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(name, scope = nil) ⇒ NestedAttribute
constructor
A new instance of NestedAttribute.
- #scoped_name(prefix = nil) ⇒ Object
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'app/models/pigeon/nested_attribute.rb', line 3 def name @name end |
#scope ⇒ Object (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 |