Module: Marquery::Model
- Included in:
- Entry
- Defined in:
- lib/marquery/model.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #active? ⇒ Boolean
- #hash ⇒ Object
- #initialize(attrs = {}) ⇒ Object
- #to_h ⇒ Object
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
13 14 15 |
# File 'lib/marquery/model.rb', line 13 def content @content end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
13 14 15 |
# File 'lib/marquery/model.rb', line 13 def date @date end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
13 14 15 |
# File 'lib/marquery/model.rb', line 13 def description @description end |
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
13 14 15 |
# File 'lib/marquery/model.rb', line 13 def slug @slug end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
13 14 15 |
# File 'lib/marquery/model.rb', line 13 def source @source end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
13 14 15 |
# File 'lib/marquery/model.rb', line 13 def title @title end |
Class Method Details
.included(base) ⇒ Object
8 9 10 11 |
# File 'lib/marquery/model.rb', line 8 def self.included(base) base.include(Marquery::Renderable) base.include(Marquery::Attributable) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
23 24 25 |
# File 'lib/marquery/model.rb', line 23 def ==(other) other.is_a?(self.class) && other.slug == slug end |
#active? ⇒ Boolean
21 |
# File 'lib/marquery/model.rb', line 21 def active? = @active |
#hash ⇒ Object
28 |
# File 'lib/marquery/model.rb', line 28 def hash = [self.class, slug].hash |
#initialize(attrs = {}) ⇒ Object
15 16 17 18 19 |
# File 'lib/marquery/model.rb', line 15 def initialize(attrs = {}) attrs = attrs.transform_keys(&:to_sym) assign_standard_attributes(attrs) assign_declared_attributes(attrs) end |
#to_h ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/marquery/model.rb', line 30 def to_h { slug:, title:, description:, content:, date:, active: active?, source:, assets: }.tap do |base| self.class.attributes.each_key do |name| base[name] = public_send(name) end end end |