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.
61 62 63 64 65 66 67 68 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 61 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.
59 60 61 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 59 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
59 60 61 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 59 def id @id end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
59 60 61 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 59 def @options end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
59 60 61 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 59 def target @target end |
Instance Method Details
#applies?(view) ⇒ Boolean
74 75 76 77 78 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 74 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
70 71 72 |
# File 'lib/rails_ext/action_controller/content_for_assignments.rb', line 70 def render(view) view.content_for(target, eval_content(view)) if applies?(view) end |