Class: RegisteredContent
- Defined in:
- lib/rails_ext/action_controller/content_for_assignments.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #applies?(view) ⇒ Boolean
-
#initialize(id, target, *args, &block) ⇒ RegisteredContent
constructor
A new instance of RegisteredContent.
- #render(view) ⇒ Object
Constructor Details
#initialize(id, target, *args, &block) ⇒ RegisteredContent
Returns a new instance of RegisteredContent.
60 61 62 63 64 65 66 67 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 60 def initialize(id, target, *args, &block) @id = id @target = target @options = args. @content = block_given? ? block : args.first end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
58 59 60 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 58 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
58 59 60 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 58 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
58 59 60 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 58 def @options end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
58 59 60 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 58 def target @target end |
Instance Method Details
#applies?(view) ⇒ Boolean
73 74 75 76 77 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 73 def applies?(view) included = [:only] ? condition_applies?(:only, view) : true excluded = [:except] ? condition_applies?(:except, view) : false included and not excluded end |
#render(view) ⇒ Object
69 70 71 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 69 def render(view) view.content_for(target, eval_content(view)) if applies?(view) end |