Class: Nanoc::Core::DependencyProps Private
- Inherits:
-
Object
- Object
- Nanoc::Core::DependencyProps
- Includes:
- ContractsSupport
- Defined in:
- lib/nanoc/core/dependency_props.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- C_RAW_CONTENT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
TODO: Split raw_content for documents and collections
C::Or[C::IterOf[C::Or[String, Regexp]], C::Bool]
- C_ATTRS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
C::Or[C::IterOf[Symbol], C::Bool]
Instance Attribute Summary collapse
- #attributes ⇒ Object readonly private
- #raw_content ⇒ Object readonly private
Instance Method Summary collapse
- #active ⇒ Object private
- #attributes? ⇒ Boolean private
- #compiled_content? ⇒ Boolean private
-
#initialize(raw_content: false, attributes: false, compiled_content: false, path: false) ⇒ DependencyProps
constructor
private
A new instance of DependencyProps.
- #inspect ⇒ Object private
- #merge(other) ⇒ Object private
- #merge_attributes(other) ⇒ Object private
- #merge_prop(own, other) ⇒ Object private
- #merge_raw_content(other) ⇒ Object private
- #path? ⇒ Boolean private
- #raw_content? ⇒ Boolean private
- #to_h ⇒ Object private
- #to_s ⇒ Object private
Methods included from ContractsSupport
enabled?, included, setup_once, warn_about_performance
Constructor Details
#initialize(raw_content: false, attributes: false, compiled_content: false, path: false) ⇒ DependencyProps
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DependencyProps.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/nanoc/core/dependency_props.rb', line 16 def initialize(raw_content: false, attributes: false, compiled_content: false, path: false) @compiled_content = compiled_content @path = path @attributes = case attributes when Set attributes when Enumerable Set.new(attributes) else attributes end @raw_content = case raw_content when Set raw_content when Enumerable Set.new(raw_content) else raw_content end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/nanoc/core/dependency_props.rb', line 9 def attributes @attributes end |
#raw_content ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/nanoc/core/dependency_props.rb', line 10 def raw_content @raw_content end |
Instance Method Details
#active ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
130 131 132 133 134 135 136 137 |
# File 'lib/nanoc/core/dependency_props.rb', line 130 def active Set.new.tap do |pr| pr << :raw_content if raw_content? pr << :attributes if attributes? pr << :compiled_content if compiled_content? pr << :path if path? end end |
#attributes? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
74 75 76 77 78 79 80 81 |
# File 'lib/nanoc/core/dependency_props.rb', line 74 def attributes? case @attributes when Enumerable @attributes.any? else @attributes end end |
#compiled_content? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
84 85 86 |
# File 'lib/nanoc/core/dependency_props.rb', line 84 def compiled_content? @compiled_content end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/nanoc/core/dependency_props.rb', line 42 def inspect (+'').tap do |s| s << 'Props(' s << (raw_content? ? 'r' : '_') s << (attributes? ? 'a' : '_') s << (compiled_content? ? 'c' : '_') s << (path? ? 'p' : '_') s << ')' end end |
#merge(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
94 95 96 97 98 99 100 101 |
# File 'lib/nanoc/core/dependency_props.rb', line 94 def merge(other) DependencyProps.new( raw_content: merge_raw_content(other), attributes: merge_attributes(other), compiled_content: compiled_content? || other.compiled_content?, path: path? || other.path?, ) end |
#merge_attributes(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
107 108 109 |
# File 'lib/nanoc/core/dependency_props.rb', line 107 def merge_attributes(other) merge_prop(attributes, other.attributes) end |
#merge_prop(own, other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/nanoc/core/dependency_props.rb', line 111 def merge_prop(own, other) case own when true true when false other else case other when true true when false own else own + other end end end |
#merge_raw_content(other) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
103 104 105 |
# File 'lib/nanoc/core/dependency_props.rb', line 103 def merge_raw_content(other) merge_prop(raw_content, other.raw_content) end |
#path? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 |
# File 'lib/nanoc/core/dependency_props.rb', line 89 def path? @path end |
#raw_content? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
64 65 66 67 68 69 70 71 |
# File 'lib/nanoc/core/dependency_props.rb', line 64 def raw_content? case @raw_content when Enumerable @raw_content.any? else @raw_content end end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
140 141 142 143 144 145 146 147 |
# File 'lib/nanoc/core/dependency_props.rb', line 140 def to_h { raw_content: raw_content, attributes: attributes, compiled_content: compiled_content?, path: path?, } end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 57 58 59 60 61 |
# File 'lib/nanoc/core/dependency_props.rb', line 54 def to_s (+'').tap do |s| s << (raw_content? ? 'r' : '_') s << (attributes? ? 'a' : '_') s << (compiled_content? ? 'c' : '_') s << (path? ? 'p' : '_') end end |