Class: Rubyists::Linear::BaseModel
- Inherits:
-
Object
- Object
- Rubyists::Linear::BaseModel
show all
- Extended by:
- GQLi::DSL, ClassMethods
- Includes:
- GQLi::DSL, SemanticLogger::Loggable
- Defined in:
- lib/linear/models/base_model.rb,
lib/linear/models/base_model/method_magic.rb,
lib/linear/models/base_model/class_methods.rb
Overview
The base model for all Linear models
Defined Under Namespace
Modules: ClassMethods, MethodMagic
Constant Summary
collapse
- CANCELLED_STATES =
%w[cancelled canceled].freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
all, all_query, allq, base_fragment, basic_filter, const_added, find, full_fragment, getter!, gql_query, just_name, many_setter!, many_to_one, one_to_many, plural, setter!
Constructor Details
#initialize(data) ⇒ BaseModel
Returns a new instance of BaseModel.
22
23
24
25
26
|
# File 'lib/linear/models/base_model.rb', line 22
def initialize(data)
data.each_key { |k| raise SmellsBad, "Unknown key #{k}" unless respond_to? "#{k}=" }
@data = data
@updated_data = data.dup
end
|
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
18
19
20
|
# File 'lib/linear/models/base_model.rb', line 18
def data
@data
end
|
#updated_data ⇒ Object
Returns the value of attribute updated_data.
18
19
20
|
# File 'lib/linear/models/base_model.rb', line 18
def updated_data
@updated_data
end
|
Instance Method Details
#cancelled_states ⇒ Object
36
37
38
|
# File 'lib/linear/models/base_model.rb', line 36
def cancelled_states
workflow_states.select { |ws| CANCELLED_STATES.include? ws.type }
end
|
#changed? ⇒ Boolean
28
29
30
|
# File 'lib/linear/models/base_model.rb', line 28
def changed?
data != updated_data
end
|
#completed_states ⇒ Object
32
33
34
|
# File 'lib/linear/models/base_model.rb', line 32
def completed_states
workflow_states.select { |ws| ws.type == 'completed' }
end
|
#inspect ⇒ Object
52
53
54
|
# File 'lib/linear/models/base_model.rb', line 52
def inspect
format '#<%<name>s:%<id>s %<inspection>s>', name: self.class.name, id:, inspection:
end
|
#inspection ⇒ Object
48
49
50
|
# File 'lib/linear/models/base_model.rb', line 48
def inspection
format('name: "%<name>s"', name:)
end
|
#to_h ⇒ Object
40
41
42
|
# File 'lib/linear/models/base_model.rb', line 40
def to_h
updated_data
end
|
#to_json(*_args) ⇒ Object
44
45
46
|
# File 'lib/linear/models/base_model.rb', line 44
def to_json(*_args)
updated_data.to_json
end
|